home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1994 #2 / Monster Media No. 2 (Monster Media)(1994).ISO / freq_qa / unix0694.zip / UNIX0694.TXT < prev   
Text File  |  1994-06-07  |  172KB  |  4,177 lines

  1. Archive-name: unix-faq/faq/contents
  2. Version: $Id: contents,v 2.5 1994/04/28 19:25:03 tmatimar Exp $
  3.  
  4. The following seven articles contain the answers to some Frequently Asked
  5. Questions often seen in comp.unix.questions and comp.unix.shell.
  6. Please don't ask these questions again, they've been answered plenty
  7. of times already - and please don't flame someone just because they may
  8. not have read this particular posting.  Thank you.
  9.  
  10. This collection of documents is Copyright (c) 1994, Ted Timar.
  11. All rights reserved.  Permission to distribute the collection is
  12. hereby granted providing that distribution is electronic, no money
  13. is involved, reasonable attempts are made to use the latest version
  14. and all credits and this copyright notice are maintained.
  15. Other requests for distribution will be considered.
  16.  
  17. All information here has been contributed with good intentions, but
  18. none of it is guaranteed either by the contributors or myself to be
  19. accurate.  The users of this information take all responsibility for
  20. any damage that may occur.
  21.  
  22. Many FAQs, including this one, are available on the archive site
  23. rtfm.mit.edu in the directory pub/usenet/news.answers.
  24. The name under which a FAQ is archived appears in the "Archive-Name:"
  25. line at the top of the article.  This FAQ is archived as
  26. "unix-faq/faq/part[1-7]".
  27.  
  28. These articles are divided approximately as follows:
  29.  
  30.       1.*) General questions.
  31.       2.*) Relatively basic questions, likely to be asked by beginners.
  32.       3.*) Intermediate questions.
  33.       4.*) Advanced questions, likely to be asked by people who thought
  34.     they already knew all of the answers.
  35.       5.*) Questions pertaining to the various shells, and the differences.
  36.       6.*) An overview of Unix variants.
  37.       7.*) An comparison of configuration management systems (RCS, SCCS).
  38.  
  39. The following questions are answered:
  40.  
  41.       1.1)  Who helped you put this list together?
  42.       1.2)  When someone refers to 'rn(1)' or 'ctime(3)', what does
  43.               the number in parentheses mean?
  44.       1.3)  What does {some strange unix command name} stand for?
  45.       1.4)  How does the gateway between "comp.unix.questions" and the
  46.               "info-unix" mailing list work?
  47.       1.5)  What are some useful Unix or C books?
  48.       1.6)  What happened to the pronunciation list that used to be
  49.               part of this document?
  50.  
  51.       2.1)  How do I remove a file whose name begins with a "-" ?
  52.       2.2)  How do I remove a file with funny characters in the filename ?
  53.       2.3)  How do I get a recursive directory listing?
  54.       2.4)  How do I get the current directory into my prompt?
  55.       2.5)  How do I read characters from the terminal in a shell script?
  56.       2.6)  How do I rename "*.foo" to "*.bar", or change file names
  57.               to lowercase?
  58.       2.7)  Why do I get [some strange error message] when I
  59.               "rsh host command" ?
  60.       2.8)  How do I {set an environment variable, change directory} inside a
  61.               program or shell script and have that change affect my
  62.               current shell?
  63.       2.9)  How do I redirect stdout and stderr separately in csh?
  64.       2.10) How do I tell inside .cshrc if I'm a login shell?
  65.       2.11) How do I construct a shell glob-pattern that matches all files
  66.             except "." and ".." ?
  67.       2.12) How do I find the last argument in a Bourne shell script?
  68.       2.13) What's wrong with having '.' in your $PATH ?
  69.       2.14) How do I ring the terminal bell during a shell script?
  70.       2.15) Why can't I use "talk" to talk with my friend on machine X?
  71.  
  72.       3.1)  How do I find the creation time of a file?
  73.       3.2)  How do I use "rsh" without having the rsh hang around
  74.               until the remote command has completed?
  75.       3.3)  How do I truncate a file?
  76.       3.4)  Why doesn't find's "{}" symbol do what I want?
  77.       3.5)  How do I set the permissions on a symbolic link?
  78.       3.6)  How do I "undelete" a file?
  79.       3.7)  How can a process detect if it's running in the background?
  80.       3.8)  Why doesn't redirecting a loop work as intended?  (Bourne shell)
  81.       3.9)  How do I run 'passwd', 'ftp', 'telnet', 'tip' and other
  82. interactive
  83.               programs from a shell script or in the background?
  84.       3.10) How do I find the process ID of a program with a particular
  85.             name from inside a shell script or C program?
  86.       3.11) How do I check the exit status of a remote command
  87.             executed via "rsh" ?
  88.       3.12) Is it possible to pass shell variable settings into an awk
  89. program?
  90.       3.13) How do I get rid of zombie processes that persevere?
  91.       3.14) How do I get lines from a pipe as they are written instead of
  92.             only in larger blocks.
  93.  
  94.       4.1)  How do I read characters from a terminal without requiring the
  95. user
  96.               to hit RETURN?
  97.       4.2)  How do I check to see if there are characters to be read without
  98.               actually reading?
  99.       4.3)  How do I find the name of an open file?
  100.       4.4)  How can an executing program determine its own pathname?
  101.       4.5)  How do I use popen() to open a process for reading AND writing?
  102.       4.6)  How do I sleep() in a C program for less than one second?
  103.       4.7)  How can I get setuid shell scripts to work?
  104.       4.8)  How can I find out which user or process has a file open or is
  105. using
  106.             a particular file system (so that I can unmount it?)
  107.       4.9)  How do I keep track of people who are fingering me?
  108.       4.10) Is it possible to reconnect a process to a terminal after it has
  109.             been disconnected, e.g. after starting a program in the background
  110.             and logging out?
  111.       4.11) Is it possible to "spy" on a terminal, displaying the output
  112.             that's appearing on it on another terminal?
  113.  
  114.       5.1)  Can shells be classified into categories?
  115.       5.2)  How do I "include" one shell script from within another
  116.             shell script?
  117.       5.3)  Do all shells have aliases?  Is there something else that
  118.             can be used?
  119.       5.4)  How are shell variables assigned?
  120.       5.5)  How can I tell if I am running an interactive shell?
  121.       5.6)  What "dot" files do the various shells use?
  122.       5.7)  I would like to know more about the differences between the
  123.             various shells.  Is this information available some place?
  124.  
  125.       6.1)  Disclaimer and introduction.
  126.       6.2)  A very brief look at Unix history.
  127.       6.3)  Main Unix flavors.
  128.       6.4)  Unix Standards.
  129.       6.5)  Identifying your Unix flavor.
  130.       6.6)  Brief notes on some well-known (commercial/PD) Unices.
  131.       6.7)  Real-time Unices.
  132.       6.8)  Unix glossary.
  133.       6.9)  Acknowledgements.
  134.  
  135.       7.1)  RCS vs SCCS:  Introduction
  136.       7.2)  RCS vs SCCS:  How do the interfaces compare?
  137.       7.3)  RCS vs SCCS:  What's in a Revision File?
  138.       7.4)  RCS vs SCCS:  What are the keywords?
  139.       7.5)  What's an RCS symbolic name?
  140.       7.6)  RCS vs SCCS:  How do they compare for performance?
  141.       7.7)  RCS vs SCCS:  Version Identification.
  142.       7.8)  RCS vs SCCS:  How do they handle with problems?
  143.       7.9)  RCS vs SCCS:  How do they interact with make(1)?
  144.       7.10) RCS vs SCCS:  Conversion.
  145.       7.11) RCS vs SCCS:  Support
  146.       7.12) RCS vs SCCS:  Command Comparison
  147.       7.13) RCS vs SCCS:  Acknowledgements
  148.       7.14) Can I get more information on configuration management systems?
  149.  
  150.       If you're looking for the answer to, say, question 2.5, look in
  151.       part 2 and search for the regular expression "^2.5)".
  152.  
  153. While these are all legitimate questions, they seem to crop up in
  154. comp.unix.questions or comp.unix.shell on an annual basis, usually
  155. followed by plenty of replies (only some of which are correct) and then
  156. a period of griping about how the same questions keep coming up.  You
  157. may also like to read the monthly article "Answers to Frequently Asked
  158. Questions" in the newsgroup "news.announce.newusers", which will tell
  159. you what "UNIX" stands for.
  160.  
  161. With the variety of Unix systems in the world, it's hard to guarantee
  162. that these answers will work everywhere.  Read your local manual pages
  163. before trying anything suggested here.  If you have suggestions or
  164. corrections for any of these answers, please send them to to
  165. tmatimar@isgtec.com.
  166.  
  167. --
  168. Ted Timar - tmatimar@isgtec.com
  169. ISG Technologies Inc., 6509 Airport Road, Mississauga, Ontario, Canada L4V 1S7
  170.  
  171.  
  172. -------------------------------------------------------------------------------
  173. Area # 2120  news.answers           05-30-94 04:34      Message # 13343
  174. From    : Ted Timar
  175. To      : ALL                                           
  176. Subj    : Unix - Frequently Asked
  177.  
  178.  @FROM   :tmatimar@isgtec.com                                          
  179.  @SUBJECT:Unix - Frequently Asked Questions (1/7) [Frequent posting]   
  180.  @PACKOUT:05-31-9440,3193382879                                        
  181. Message-ID: <unix-faq/faq/part1_770286840@rtfm.mit.edu>
  182. Newsgroups: comp.unix.questions,comp.unix.shell,comp.answers,news.answers
  183. Organization: ISG Technologies, Inc
  184.  
  185. Archive-name: unix-faq/faq/part1
  186. Version: $Id: part1,v 2.5 1994/04/28 19:25:03 tmatimar Exp $
  187.  
  188. These seven articles contain the answers to some Frequently Asked
  189. Questions often seen in comp.unix.questions and comp.unix.shell.
  190. Please don't ask these questions again, they've been answered plenty
  191. of times already - and please don't flame someone just because they may
  192. not have read this particular posting.  Thank you.
  193.  
  194. This collection of documents is Copyright (c) 1994, Ted Timar.
  195. All rights reserved.  Permission to distribute the collection is
  196. hereby granted providing that distribution is electronic, no money
  197. is involved, reasonable attempts are made to use the latest version
  198. and all credits and this copyright notice are maintained.
  199. Other requests for distribution will be considered.
  200.  
  201. All information here has been contributed with good intentions, but
  202. none of it is guaranteed either by the contributors or myself to be
  203. accurate.  The users of this information take all responsibility for
  204. any damage that may occur.
  205.  
  206. Many FAQs, including this one, are available on the archive site
  207. rtfm.mit.edu in the directory pub/usenet/news.answers.
  208. The name under which a FAQ is archived appears in the "Archive-Name:"
  209. line at the top of the article.  This FAQ is archived as
  210. "unix-faq/faq/part[1-7]".
  211.  
  212. These articles are divided approximately as follows:
  213.  
  214.       1.*) General questions.
  215.       2.*) Relatively basic questions, likely to be asked by beginners.
  216.       3.*) Intermediate questions.
  217.       4.*) Advanced questions, likely to be asked by people who thought
  218.     they already knew all of the answers.
  219.       5.*) Questions pertaining to the various shells, and the differences.
  220.       6.*) An overview of Unix variants.
  221.       7.*) An comparison of configuration management systems (RCS, SCCS).
  222.  
  223. This article includes answers to:
  224.  
  225.       1.1)  Who helped you put this list together?
  226.       1.2)  When someone refers to 'rn(1)' or 'ctime(3)', what does
  227.               the number in parentheses mean?
  228.       1.3)  What does {some strange unix command name} stand for?
  229.       1.4)  How does the gateway between "comp.unix.questions" and the
  230.               "info-unix" mailing list work?
  231.       1.5)  What are some useful Unix or C books?
  232.       1.6)  What happened to the pronunciation list that used to be
  233.               part of this document?
  234.  
  235. If you're looking for the answer to, say, question 1.5, and want to skip
  236. everything else, you can search ahead for the regular expression "^1.5)".
  237.  
  238. While these are all legitimate questions, they seem to crop up in
  239. comp.unix.questions or comp.unix.shell on an annual basis, usually
  240. followed by plenty of replies (only some of which are correct) and then
  241. a period of griping about how the same questions keep coming up.  You
  242. may also like to read the monthly article "Answers to Frequently Asked
  243. Questions" in the newsgroup "news.announce.newusers", which will tell
  244. you what "UNIX" stands for.
  245.  
  246. With the variety of Unix systems in the world, it's hard to guarantee
  247. that these answers will work everywhere.  Read your local manual pages
  248. before trying anything suggested here.  If you have suggestions or
  249. corrections for any of these answers, please send them to to
  250. tmatimar@isgtec.com.
  251.  
  252. ----------------------------------------------------------------------
  253.  
  254. Subject: Who helped you put this list together?
  255. Date: Thu Mar 18 17:16:55 EST 1993
  256.  
  257. 1.1)  Who helped you put this list together?
  258.  
  259.       I took over the maintenance of this list.  Almost all of the work
  260.       (and the credit) for generating this compilation was done by
  261.       Steve Hayman.
  262.  
  263.       We also owe a great deal of thanks to dozens of Usenet readers who
  264.       submitted questions, answers, corrections and suggestions for this
  265.       list.  Special thanks go to Maarten Litmaath, Guy Harris and
  266.       Jonathan Kamens, who have all made many especially valuable
  267.       contributions.
  268.  
  269.       Part 5 of this document (shells) was written almost entirely by
  270.       Matthew Wicks <wicks@dcdmjw.fnal.gov>.
  271.  
  272.       Part 6 of this document (Unix flavours) was written almost entirely by
  273.       Pierre (P.) Lewis <lew@bnr.ca>.
  274.  
  275.       Where possible the author of each question and the date it was last
  276.       updated is given at the top.  Unfortunately, I only started this
  277.       practice recently, and much of the information is lost.  I was also
  278.       negligent in keeping track of who provided updates to questions.
  279.       Sorry to those who have made valuable contributions, but did not
  280.       receive the credit and recognition that they legitimately deserve.
  281.  
  282. ------------------------------
  283.  
  284. Subject: When someone refers to 'rn(1)' ...  the number in parentheses mean?
  285. Date: Thu Mar 18 17:16:55 EST 1993
  286.  
  287. 1.2)  When someone refers to 'rn(1)' or 'ctime(3)', what does
  288.       the number in parentheses mean?
  289.  
  290.       It looks like some sort of function call, but it isn't.  These
  291.       numbers refer to the section of the "Unix manual" where the
  292.       appropriate documentation can be found.  You could type
  293.       "man 3 ctime" to look up the manual page for "ctime" in section 3
  294.       of the manual.
  295.  
  296.       The traditional manual sections are:
  297.  
  298.  1 User-level  commands
  299.  2 System calls
  300.  3 Library functions
  301.  4 Devices and device drivers
  302.  5 File formats
  303.  6 Games
  304.  7 Various miscellaneous stuff - macro packages etc.
  305.  8 System maintenance and operation commands
  306.  
  307.       Some Unix versions use non-numeric section names.  For instance,
  308.       Xenix uses "C" for commands and "S" for functions.  Some newer
  309.       versions of Unix require "man -s# title" instead of "man # title".
  310.  
  311.       Each section has an introduction, which you can read with "man #
  312.       intro" where # is the section number.
  313.  
  314.       Sometimes the number is necessary to differentiate between a
  315.       command and a library routine or system call of the same name.
  316.       For instance, your system may have "time(1)", a manual page about
  317.       the 'time' command for timing programs, and also "time(3)", a
  318.       manual page about the 'time' subroutine for determining the
  319.       current time.  You can use "man 1 time" or "man 3 time" to
  320.       specify which "time" man page you're interested in.
  321.  
  322.       You'll often find other sections for local programs or even
  323.       subsections of the sections above - Ultrix has sections 3m, 3n,
  324.       3x and 3yp among others.
  325.  
  326. ------------------------------
  327.  
  328. Subject: What does {some strange unix command name} stand for?
  329. Date: Thu Mar 18 17:16:55 EST 1993
  330.  
  331. 1.3)  What does {some strange unix command name} stand for?
  332.  
  333.       awk = "Aho Weinberger and Kernighan"
  334.  
  335.  This language was named by its authors, Al Aho, Peter
  336.  Weinberger and Brian Kernighan.
  337.  
  338.       grep = "Global Regular Expression Print"
  339.  
  340.  grep comes from the ed command to print all lines matching a
  341.  certain pattern
  342.  
  343.       g/re/p
  344.  
  345.  where "re" is a "regular expression".
  346.  
  347.       fgrep = "Fixed GREP".
  348.  
  349.  fgrep searches for fixed strings only.  The "f" does not stand
  350.  for "fast" - in fact, "fgrep foobar *.c" is usually slower than
  351.  "egrep foobar *.c"  (Yes, this is kind of surprising. Try it.)
  352.  
  353.  Fgrep still has its uses though, and may be useful when searching
  354.  a file for a larger number of strings than egrep can handle.
  355.  
  356.       egrep = "Extended GREP"
  357.  
  358.  egrep uses fancier regular expressions than grep.  Many people
  359.  use egrep all the time, since it has some more sophisticated
  360.  internal algorithms than grep or fgrep, and is usually the
  361.  fastest of the three programs.
  362.  
  363.       cat = "CATenate"
  364.  
  365.  catenate is an obscure word meaning "to connect in a series",
  366.  which is what the "cat" command does to one or more files.  Not
  367.  to be confused with C/A/T, the Computer Aided Typesetter.
  368.  
  369.       gecos = "General Electric Comprehensive Operating System"
  370.  
  371.  When GE's large systems division was sold to Honeywell,
  372.  Honeywell dropped the "E" from "GECOS".
  373.  
  374.  Unix's password file has a "pw_gecos" field.  The name is a
  375.  real holdover from the early days.  Dennis Ritchie has reported:
  376.  
  377.      "Sometimes we sent printer output or batch jobs
  378.       to the GCOS machine.  The gcos field in the password file
  379.       was a place to stash the information for the $IDENT card.
  380.       Not elegant."
  381.  
  382.       nroff = "New ROFF"
  383.       troff = "Typesetter new ROFF"
  384.  
  385.  These are descendants of "roff", which was a re-implementation
  386.  of the Multics "runoff" program (a program that you'd use to
  387.  "run off" a good copy of a document).
  388.  
  389.       tee       = T
  390.  
  391.  From plumbing terminology for a T-shaped pipe splitter.
  392.  
  393.       bss = "Block Started by Symbol"
  394.  
  395.  Dennis Ritchie says:
  396.  
  397.      Actually the acronym (in the sense we took it up; it may
  398.      have other credible etymologies) is "Block Started by
  399.      Symbol." It was a pseudo-op in FAP (Fortran Assembly [-er?]
  400.      Program), an assembler for the IBM 704-709-7090-7094
  401.      machines.  It defined its label and set aside space for a
  402.      given number of words.  There was another pseudo-op, BES,
  403.      "Block Ended by Symbol" that did the same except that the
  404.      label was defined by the last assigned word + 1.  (On these
  405.      machines Fortran arrays were stored backwards in storage
  406.      and were 1-origin.)
  407.  
  408.      The usage is reasonably appropriate, because just as with
  409.      standard Unix loaders, the space assigned didn't have to be
  410.      punched literally into the object deck but was represented
  411.      by a count somewhere.
  412.  
  413.       biff = "BIFF"
  414.  
  415.  This command, which turns on asynchronous mail notification,
  416.  was actually named after a dog at Berkeley.
  417.  
  418.      I can confirm the origin of biff, if you're interested.
  419.      Biff was Heidi Stettner's dog, back when Heidi (and I, and
  420.      Bill Joy) were all grad students at U.C. Berkeley and the
  421.      early versions of BSD were being developed.   Biff was
  422.      popular among the residents of Evans Hall, and was known
  423.      for barking at the mailman, hence the name of the command.
  424.  
  425.  Confirmation courtesy of Eric Cooper, Carnegie Mellon University
  426.  
  427.       rc (as in ".cshrc" or "/etc/rc") = "RunCom"
  428.  
  429.  "rc" derives from "runcom", from the MIT CTSS system, ca. 1965.
  430.  
  431.      'There was a facility that would execute a bunch of
  432.      commands stored in a file; it was called "runcom" for "run
  433.      commands", and the file began to be called "a runcom."
  434.  
  435.      "rc" in Unix is a fossil from that usage.'
  436.  
  437.  Brian Kernighan & Dennis Ritchie, as told to Vicki Brown
  438.  
  439.  "rc" is also the name of the shell from the new Plan 9
  440.  operating system.
  441.  
  442.       Perl = "Practical Extraction and Report Language"
  443.       Perl = "Pathologically Eclectic Rubbish Lister"
  444.  
  445.  The Perl language is Larry Wall's highly popular
  446.  freely-available completely portable text, process, and file
  447.  manipulation tool that bridges the gap between shell and C
  448.  programming (or between doing it on the command line and
  449.  pulling your hair out).  For further information, see the
  450.  Usenet newsgroup comp.lang.perl.
  451.  
  452.       Don Libes' book "Life with Unix" contains lots more of these
  453.       tidbits.
  454.  
  455. ------------------------------
  456.  
  457. Subject: How does the gateway between "comp.unix.questions" ... work ?
  458. Date: Thu Mar 18 17:16:55 EST 1993
  459.  
  460. 1.4)  How does the gateway between "comp.unix.questions" and the
  461.       "info-unix" mailing list work?
  462.  
  463.       "info-unix" and "unix-wizards" are mailing list versions of
  464.       comp.unix.questions and comp.unix.wizards respectively.
  465.       There should be no difference in content between the
  466.       mailing list and the newsgroup.
  467.  
  468.       To get on or off either of these lists, send mail to
  469.       info-unix-request@brl.mil or unix-wizards-request@brl.mil.
  470.       Be sure to use the '-Request'.  Don't expect an immediate response.
  471.  
  472.       Here are the gory details, courtesy of the list's maintainer,
  473.       Bob Reschly.
  474.  
  475.       ==== postings to info-UNIX and UNIX-wizards lists ====
  476.  
  477.       Anything submitted to the list is posted; I do not moderate
  478.       incoming traffic -- BRL functions as a reflector.  Postings
  479.       submitted by Internet subscribers should be addressed to the list
  480.       address (info-UNIX or UNIX- wizards);  the '-request' addresses
  481.       are for correspondence with the list maintainer [me].  Postings
  482.       submitted by USENET readers should be addressed to the
  483.       appropriate news group (comp.unix.questions or
  484.       comp.unix.wizards).
  485.  
  486.       For Internet subscribers, received traffic will be of two types;
  487.       individual messages, and digests.  Traffic which comes to BRL
  488.       from the Internet and BITNET (via the BITNET-Internet gateway) is
  489.       immediately resent to all addressees on the mailing list.
  490.       Traffic originating on USENET is gathered up into digests which
  491.       are sent to all list members daily.
  492.  
  493.       BITNET traffic is much like Internet traffic.  The main
  494.       difference is that I maintain only one address for traffic
  495.       destined to all BITNET subscribers. That address points to a list
  496.       exploder which then sends copies to individual BITNET
  497.       subscribers.  This way only one copy of a given message has to
  498.       cross the BITNET-Internet gateway in either direction.
  499.  
  500.       USENET subscribers see only individual messages.  All messages
  501.       originating on the Internet side are forwarded to our USENET
  502.       machine.  They are then posted to the appropriate newsgroup.
  503.       Unfortunately, for gatewayed messages, the sender becomes
  504.       "news@brl-adm".  This is currently an unavoidable side-effect of
  505.       the software which performs the gateway function.
  506.  
  507.       As for readership, USENET has an extremely large readership - I
  508.       would guess several thousand hosts and tens of thousands of
  509.       readers.  The master list maintained here at BRL runs about two
  510.       hundred fifty entries with roughly ten percent of those being
  511.       local redistribution lists.  I don't have a good feel for the
  512.       size of the BITNET redistribution, but I would guess it is
  513.       roughly the same size and composition as the master list.
  514.       Traffic runs 150K to 400K bytes per list per week on average.
  515.  
  516. ------------------------------
  517.  
  518. Subject: What are some useful Unix or C books?
  519. Date: Thu Mar 18 17:16:55 EST 1993
  520.  
  521. 1.5)  What are some useful Unix or C books?
  522.  
  523.       Mitch Wright (mitch@cirrus.com) maintains a useful list of Unix
  524.       and C books, with descriptions and some mini-reviews.  There are
  525.       currently 167 titles on his list.
  526.  
  527.       You can obtain a copy of this list by anonymous ftp from
  528.       ftp.rahul.net (192.160.13.1), where it's "pub/mitch/YABL/yabl".
  529.       Send additions or suggestions to mitch@cirrus.com.
  530.  
  531.       Samuel Ko (kko@sfu.ca) maintains another list of Unix books.
  532.       This list contains only recommended books, and is therefore
  533.       somewhat shorter.  This list is also a classified list, with
  534.       books grouped into categories, which may be better if you are
  535.       looking for a specific type of book.
  536.  
  537.       You can obtain a copy of this list by anonymous ftp from
  538.       rtfm.mit.edu, where it's "pub/usenet/news.answers/books/unix".
  539.       Send additions or suggestions to kko@sfu.ca.
  540.  
  541.       If you can't use anonymous ftp, email the line "help" to
  542.       "ftpmail@decwrl.dec.com" for instructions on retrieving
  543.       things via email.
  544.  
  545. ------------------------------
  546.  
  547. Subject: What happened to the pronunciation list ... ?
  548. Date: Thu Mar 18 17:16:55 EST 1993
  549.  
  550. 1.6)  What happened to the pronunciation list that used to be part of this
  551.       document?
  552.  
  553.       From its inception in 1989, this FAQ document included a
  554.       comprehensive pronunciation list maintained by Maarten Litmaath
  555.       (thanks, Maarten!).  It was originally created by Carl Paukstis
  556.       <carlp@frigg.isc-br.com>.
  557.  
  558.       It has been retired, since it is not really relevant to the topic
  559.       of "Unix questions".  You can still find it as part of the
  560.       widely-distributed "Jargon" file (maintained by Eric S. Raymond,
  561.       eric@snark.thyrsus.com) which seems like a much more appropriate
  562.       forum for the topic of "How do you pronounce  /* ?"
  563.  
  564.       If you'd like a copy, you can ftp one from ftp.wg.omron.co.jp
  565.       (133.210.4.4), it's "pub/unix-faq/docs/Pronunciation-Guide".
  566.  
  567. ------------------------------
  568.  
  569. End of unix/faq Digest part 1 of 7
  570. **********************************
  571.  
  572. --
  573. Ted Timar - tmatimar@isgtec.com
  574. ISG Technologies Inc., 6509 Airport Road, Mississauga, Ontario, Canada L4V 1S7
  575.  
  576.  
  577. -------------------------------------------------------------------------------
  578. Area # 2120  news.answers           05-30-94 04:34      Message # 13344
  579. From    : Ted Timar
  580. To      : ALL                                           
  581. Subj    : Unix - Frequently Asked
  582.  
  583.  @FROM   :tmatimar@isgtec.com                                          
  584.  @SUBJECT:Unix - Frequently Asked Questions (2/7) [Frequent posting]   
  585.  @PACKOUT:05-31-9440,3193382879                                        
  586. Message-ID: <unix-faq/faq/part2_770286840@rtfm.mit.edu>
  587. Newsgroups: comp.unix.questions,comp.unix.shell,comp.answers,news.answers
  588. Organization: ISG Technologies, Inc
  589.  
  590. Archive-name: unix-faq/faq/part2
  591. Version: $Id: part2,v 2.5 1994/04/28 19:25:03 tmatimar Exp $
  592.  
  593. These seven articles contain the answers to some Frequently Asked
  594. Questions often seen in comp.unix.questions and comp.unix.shell.
  595. Please don't ask these questions again, they've been answered plenty
  596. of times already - and please don't flame someone just because they may
  597. not have read this particular posting.  Thank you.
  598.  
  599. This collection of documents is Copyright (c) 1994, Ted Timar.
  600. All rights reserved.  Permission to distribute the collection is
  601. hereby granted providing that distribution is electronic, no money
  602. is involved, reasonable attempts are made to use the latest version
  603. and all credits and this copyright notice are maintained.
  604. Other requests for distribution will be considered.
  605.  
  606. All information here has been contributed with good intentions, but
  607. none of it is guaranteed either by the contributors or myself to be
  608. accurate.  The users of this information take all responsibility for
  609. any damage that may occur.
  610.  
  611. Many FAQs, including this one, are available on the archive site
  612. rtfm.mit.edu in the directory pub/usenet/news.answers.
  613. The name under which a FAQ is archived appears in the "Archive-Name:"
  614. line at the top of the article.  This FAQ is archived as
  615. "unix-faq/faq/part[1-7]".
  616.  
  617. These articles are divided approximately as follows:
  618.  
  619.       1.*) General questions.
  620.       2.*) Relatively basic questions, likely to be asked by beginners.
  621.       3.*) Intermediate questions.
  622.       4.*) Advanced questions, likely to be asked by people who thought
  623.     they already knew all of the answers.
  624.       5.*) Questions pertaining to the various shells, and the differences.
  625.       6.*) An overview of Unix variants.
  626.       7.*) An comparison of configuration management systems (RCS, SCCS).
  627.  
  628. This article includes answers to:
  629.  
  630.       2.1)  How do I remove a file whose name begins with a "-" ?
  631.       2.2)  How do I remove a file with funny characters in the filename ?
  632.       2.3)  How do I get a recursive directory listing?
  633.       2.4)  How do I get the current directory into my prompt?
  634.       2.5)  How do I read characters from the terminal in a shell script?
  635.       2.6)  How do I rename "*.foo" to "*.bar", or change file names
  636.               to lowercase?
  637.       2.7)  Why do I get [some strange error message] when I
  638.               "rsh host command" ?
  639.       2.8)  How do I {set an environment variable, change directory} inside a
  640.               program or shell script and have that change affect my
  641.               current shell?
  642.       2.9)  How do I redirect stdout and stderr separately in csh?
  643.       2.10) How do I tell inside .cshrc if I'm a login shell?
  644.       2.11) How do I construct a shell glob-pattern that matches all files
  645.             except "." and ".." ?
  646.       2.12) How do I find the last argument in a Bourne shell script?
  647.       2.13) What's wrong with having '.' in your $PATH ?
  648.       2.14) How do I ring the terminal bell during a shell script?
  649.       2.15) Why can't I use "talk" to talk with my friend on machine X?
  650.  
  651. If you're looking for the answer to, say, question 2.5, and want to skip
  652. everything else, you can search ahead for the regular expression "^2.5)".
  653.  
  654. While these are all legitimate questions, they seem to crop up in
  655. comp.unix.questions or comp.unix.shell on an annual basis, usually
  656. followed by plenty of replies (only some of which are correct) and then
  657. a period of griping about how the same questions keep coming up.  You
  658. may also like to read the monthly article "Answers to Frequently Asked
  659. Questions" in the newsgroup "news.announce.newusers", which will tell
  660. you what "UNIX" stands for.
  661.  
  662. With the variety of Unix systems in the world, it's hard to guarantee
  663. that these answers will work everywhere.  Read your local manual pages
  664. before trying anything suggested here.  If you have suggestions or
  665. corrections for any of these answers, please send them to to
  666. tmatimar@isgtec.com.
  667.  
  668. ----------------------------------------------------------------------
  669.  
  670. Subject: How do I remove a file whose name begins with a "-" ?
  671. Date: Thu Mar 18 17:16:55 EST 1993
  672.  
  673. 2.1)  How do I remove a file whose name begins with a "-" ?
  674.  
  675.       Figure out some way to name the file so that it doesn't begin
  676.       with a dash.  The simplest answer is to use
  677.  
  678.      rm ./-filename
  679.  
  680.       (assuming "-filename" is in the current directory, of course.)
  681.       This method of avoiding the interpretation of the "-" works with
  682.       other commands too.
  683.  
  684.       Many commands, particularly those that have been written to use
  685.       the "getopt(3)" argument parsing routine, accept a "--" argument
  686.       which means "this is the last option, anything after this is not
  687.       an option", so your version of rm might handle "rm -- -filename".
  688.       Some versions of rm that don't use getopt() treat a single "-"
  689.       in the same way, so you can also try "rm - -filename".
  690.  
  691. ------------------------------
  692.  
  693. Subject: How do I remove a file with funny characters in the filename ?
  694. Date: Thu Mar 18 17:16:55 EST 1993
  695.  
  696. 2.2)  How do I remove a file with funny characters in the filename ?
  697.  
  698.       If the 'funny character' is a '/', skip to the last part of this
  699.       answer.  If the funny character is something else, such as a ' '
  700.       or control character or character with the 8th bit set, keep reading.
  701.  
  702.       The classic answers are
  703.  
  704.  rm -i some*pattern*that*matches*only*the*file*you*want
  705.  
  706.  which asks you whether you want to remove each file matching
  707.  the indicated pattern;  depending on your shell, this may not
  708.  work if the filename has a character with the 8th bit set (the
  709.  shell may strip that off);
  710.  
  711.       and
  712.  
  713.  rm -ri .
  714.  
  715.  which asks you whether to remove each file in the directory.
  716.  Answer "y" to the problem file and "n" to everything else.
  717.  Unfortunately this doesn't work with many versions of rm.  Also
  718.  unfortunately, this will walk through every subdirectory of ".",
  719.  so you might want to "chmod a-x" those directories temporarily
  720.  to make them unsearchable.
  721.  
  722.  Always take a deep breath and think about what you're doing and
  723.  double check what you typed when you use rm's "-r" flag or a
  724.  wildcard on the command line;
  725.  
  726.       and
  727.  
  728.  find . -type f ... -ok rm '{}' \;
  729.  
  730.       where "..." is a group of predicates that uniquely identify the
  731.       file.  One possibility is to figure out the inode number of the
  732.       problem file (use "ls -i .") and then use
  733.  
  734.  find . -inum 12345 -ok rm '{}' \;
  735.  
  736.       or
  737.  find . -inum 12345 -ok mv '{}' new-file-name \;
  738.  
  739.       "-ok" is a safety check - it will prompt you for confirmation of
  740.       the command it's about to execute.  You can use "-exec" instead
  741.       to avoid the prompting, if you want to live dangerously, or if
  742.       you suspect that the filename may contain a funny character
  743.       sequence that will mess up your screen when printed.
  744.  
  745.       What if the filename has a '/' in it?
  746.  
  747.       These files really are special cases, and can only be created by
  748.       buggy kernel code (typically by implementations of NFS that don't
  749.       filter out illegal characters in file names from remote
  750.       machines.)  The first thing to do is to try to understand exactly
  751.       why this problem is so strange.
  752.  
  753.       Recall that Unix directories are simply pairs of filenames and
  754.       inode numbers.  A directory essentially contains information
  755.       like this:
  756.  
  757.  filename  inode
  758.  
  759.  file1   12345
  760.  file2.c   12349
  761.  file3     12347
  762.  
  763.       Theoretically, '/' and '\0' are the only two characters that
  764.       cannot appear in a filename - '/' because it's used to separate
  765.       directories and files, and '\0' because it terminates a filename.
  766.  
  767.       Unfortunately some implementations of NFS will blithely create
  768.       filenames with embedded slashes in response to requests from
  769.       remote machines.  For instance, this could happen when someone on
  770.       a Mac or other non-Unix machine decides to create a remote NFS
  771.       file on your Unix machine with the date in the filename.  Your
  772.       Unix directory then has this in it:
  773.  
  774.  filename  inode
  775.  
  776.  91/02/07  12357
  777.  
  778.       No amount of messing around with 'find' or 'rm' as described
  779.       above will delete this file, since those utilities and all other
  780.       Unix programs, are forced to interpret the '/' in the normal way.
  781.  
  782.       Any ordinary program will eventually try to do
  783.       unlink("91/02/07"), which as far as the kernel is concerned means
  784.       "unlink the file 07 in the subdirectory 02 of directory 91", but
  785.       that's not what we have - we have a *FILE* named "91/02/07" in
  786.       the current directory.  This is a subtle but crucial distinction.
  787.  
  788.       What can you do in this case?  The first thing to try is to
  789.       return to the Mac that created this crummy entry, and see if you
  790.       can convince it and your local NFS daemon to rename the file to
  791.       something without slashes.
  792.  
  793.       If that doesn't work or isn't possible, you'll need help from
  794.       your system manager, who will have to try the one of the
  795.       following.  Use "ls -i" to find the inode number of this bogus
  796.       file, then unmount the file system and use "clri" to clear the
  797.       inode, and "fsck" the file system with your fingers crossed.
  798.       This destroys the information in the file.  If you want to keep
  799.       it, you can try:
  800.  
  801.  create a new directory in the same parent directory as the one
  802.  containing the bad file name;
  803.  
  804.  move everything you can (i.e. everything but the file with the
  805.  bad name) from the old directory to the new one;
  806.  
  807.  do "ls -id" on the directory containing the file with the bad
  808.  name to get its inumber;
  809.  
  810.  umount the file system;
  811.  
  812.  "clri" the directory containing the file with the bad name;
  813.  
  814.  "fsck" the file system.
  815.  
  816.       Then, to find the file,
  817.  
  818.  remount the file system;
  819.  
  820.  rename the directory you created to have the name of the old
  821.  directory (since the old directory should have been blown away
  822.  by "fsck")
  823.  
  824.  move the file out of "lost+found" into the directory with a
  825.  better name.
  826.  
  827.       Alternatively, you can patch the directory the hard way by
  828.       crawling around in the raw file system.  Use "fsdb", if you
  829.       have it.
  830.  
  831. ------------------------------
  832.  
  833. Subject: How do I get a recursive directory listing?
  834. Date: Thu Mar 18 17:16:55 EST 1993
  835.  
  836. 2.3)  How do I get a recursive directory listing?
  837.  
  838.       One of the following may do what you want:
  839.  
  840.  ls -R    (not all versions of "ls" have -R)
  841.  find . -print  (should work everywhere)
  842.  du -a .   (shows you both the name and size)
  843.  
  844.       If you're looking for a wildcard pattern that will match all ".c"
  845.       files in this directory and below, you won't find one, but you
  846.       can use
  847.  
  848.  % some-command `find . -name '*.c' -print`
  849.  
  850.       "find" is a powerful program.  Learn about it.
  851.  
  852. ------------------------------
  853.  
  854. Subject: How do I get the current directory into my prompt?
  855. Date: Thu Mar 18 17:16:55 EST 1993
  856.  
  857. 2.4)  How do I get the current directory into my prompt?
  858.  
  859.       It depends which shell you are using.  It's easy with some
  860.       shells, hard or impossible with others.
  861.  
  862.       C Shell (csh):
  863.  Put this in your .cshrc - customize the prompt variable the
  864.  way you want.
  865.  
  866.      alias setprompt 'set prompt="${cwd}% "'
  867.      setprompt  # to set the initial prompt
  868.      alias cd 'chdir \!* && setprompt'
  869.  
  870.  If you use pushd and popd, you'll also need
  871.  
  872.      alias pushd 'pushd \!* && setprompt'
  873.      alias popd  'popd  \!* && setprompt'
  874.  
  875.  Some C shells don't keep a $cwd variable - you can use
  876.  `pwd` instead.
  877.  
  878.  If you just want the last component of the current directory
  879.  in your prompt ("mail% " instead of "/usr/spool/mail% ")
  880.  you can use
  881.  
  882.      alias setprompt 'set prompt="$cwd:t% "'
  883.  
  884.  Some older csh's get the meaning of && and || reversed.
  885.  Try doing:
  886.  
  887.      false && echo bug
  888.  
  889.  If it prints "bug", you need to switch && and || (and get
  890.  a better version of csh.)
  891.  
  892.       Bourne Shell (sh):
  893.  
  894.  If you have a newer version of the Bourne Shell (SVR2 or newer)
  895.  you can use a shell function to make your own command, "xcd" say:
  896.  
  897.      xcd() { cd $* ; PS1="`pwd` $ "; }
  898.  
  899.  If you have an older Bourne shell, it's complicated but not
  900.  impossible.  Here's one way.  Add this to your .profile file:
  901.  
  902.   LOGIN_SHELL=$$ export LOGIN_SHELL
  903.   CMDFILE=/tmp/cd.$$ export CMDFILE
  904.   # 16 is SIGURG, pick a signal that's not likely to be used
  905.   PROMPTSIG=16 export PROMPTSIG
  906.   trap '. $CMDFILE' $PROMPTSIG
  907.  
  908.  and then put this executable script (without the indentation!),
  909.  let's call it "xcd", somewhere in your PATH
  910.  
  911.   : xcd directory - change directory and set prompt
  912.   : by signalling the login shell to read a command file
  913.   cat >${CMDFILE?"not set"} <<EOF
  914.   cd $1
  915.   PS1="\`pwd\`$ "
  916.   EOF
  917.   kill -${PROMPTSIG?"not set"} ${LOGIN_SHELL?"not set"}
  918.  
  919.  Now change directories with "xcd /some/dir".
  920.  
  921.       Korn Shell (ksh):
  922.  
  923.  Put this in your .profile file:
  924.   PS1='$PWD $ '
  925.  
  926.  If you just want the last component of the directory, use
  927.   PS1='${PWD##*/} $ '
  928.  
  929.       T C shell (tcsh)
  930.  
  931.  Tcsh is a popular enhanced version of csh with some extra
  932.  builtin variables (and many other features):
  933.  
  934.      %~  the current directory, using ~ for $HOME
  935.      %/  the full pathname of the current directory
  936.      %c or %. the trailing component of the current directory
  937.  
  938.  so you can do
  939.  
  940.      set prompt='%~ '
  941.  
  942.       BASH (FSF's "Bourne Again SHell")
  943.  
  944.  \w in $PS1 gives the full pathname of the current directory,
  945.  with ~ expansion for $HOME;  \W gives the basename of
  946.  the current directory.  So, in addition to the above sh and
  947.  ksh solutions, you could use
  948.  
  949.      PS1='\w $ '
  950.  or
  951.      PS1='\W $ '
  952.  
  953. ------------------------------
  954.  
  955. Subject: How do I read characters from the terminal in a shell script?
  956. Date: Thu Mar 18 17:16:55 EST 1993
  957.  
  958. 2.5)  How do I read characters from the terminal in a shell script?
  959.  
  960.       In sh, use read.  It is most common to use a loop like
  961.  
  962.      while read line
  963.      do
  964.       ...
  965.      done
  966.  
  967.       In csh, use $< like this:
  968.  
  969.      while ( 1 )
  970.   set line = "$<"
  971.   if ( "$line" == "" ) break
  972.   ...
  973.      end
  974.  
  975.       Unfortunately csh has no way of distinguishing between a blank
  976.       line and an end-of-file.
  977.  
  978.       If you're using sh and want to read a *single* character from the
  979.       terminal, you can try something like
  980.  
  981.      echo -n "Enter a character: "
  982.      stty cbreak  # or  stty raw
  983.      readchar=`dd if=/dev/tty bs=1 count=1 2>/dev/null`
  984.      stty -cbreak
  985.  
  986.      echo "Thank you for typing a $readchar ."
  987.  
  988. ------------------------------
  989.  
  990. Subject: How do I rename "*.foo" to "*.bar", or change file names to
  991. lowercase?
  992. Date: Thu Mar 18 17:16:55 EST 1993
  993.  
  994. 2.6)  How do I rename "*.foo" to "*.bar", or change file names to lowercase?
  995.  
  996.       Why doesn't "mv *.foo *.bar" work?  Think about how the shell
  997.       expands wildcards.   "*.foo" and "*.bar" are expanded before the
  998.       mv command ever sees the arguments.  Depending on your shell,
  999.       this can fail in a couple of ways.  CSH prints "No match."
  1000.       because it can't match "*.bar".  SH executes "mv a.foo b.foo
  1001.       c.foo *.bar", which will only succeed if you happen to have a
  1002.       single directory named "*.bar", which is very unlikely and almost
  1003.       certainly not what you had in mind.
  1004.  
  1005.       Depending on your shell, you can do it with a loop to "mv" each
  1006.       file individually.  If your system has "basename", you can use:
  1007.  
  1008.       C Shell:
  1009.  foreach f ( *.foo )
  1010.      set base=`basename $f .foo`
  1011.      mv $f $base.bar
  1012.  end
  1013.  
  1014.       Bourne Shell:
  1015.  for f in *.foo; do
  1016.      base=`basename $f .foo`
  1017.      mv $f $base.bar
  1018.  done
  1019.  
  1020.       Some shells have their own variable substitution features, so
  1021.       instead of using "basename", you can use simpler loops like:
  1022.  
  1023.       C Shell:
  1024.  
  1025.  foreach f ( *.foo )
  1026.      mv $f $f:r.bar
  1027.  end
  1028.  
  1029.       Korn Shell:
  1030.  
  1031.  for f in *.foo; do
  1032.      mv $f ${f%foo}bar
  1033.  done
  1034.  
  1035.       If you don't have "basename" or want to do something like
  1036.       renaming foo.* to bar.*, you can use something like "sed" to
  1037.       strip apart the original file name in other ways, but the general
  1038.       looping idea is the same.  You can also convert file names into
  1039.       "mv" commands with 'sed', and hand the commands off to "sh" for
  1040.       execution.  Try
  1041.  
  1042.  ls -d *.foo | sed -e 's/.*/mv & &/' -e 's/foo$/bar/' | sh
  1043.  
  1044.       A program by Vladimir Lanin called "mmv" that does this job
  1045.       nicely was posted to comp.sources.unix (Volume 21, issues 87 and
  1046.       88) in April 1990.  It lets you use
  1047.  
  1048.  mmv '*.foo' '=1.bar'
  1049.  
  1050.       Shell loops like the above can also be used to translate file
  1051.       names from upper to lower case or vice versa.  You could use
  1052.       something like this to rename uppercase files to lowercase:
  1053.  
  1054.  C Shell:
  1055.      foreach f ( * )
  1056.   mv $f `echo $f | tr '[A-Z]' '[a-z]'`
  1057.      end
  1058.  Bourne Shell:
  1059.      for f in *; do
  1060.   mv $f `echo $f | tr '[A-Z]' '[a-z]'`
  1061.      done
  1062.  Korn Shell:
  1063.      typeset -l l
  1064.      for f in *; do
  1065.   l="$f"
  1066.   mv $f $l
  1067.      done
  1068.  
  1069.       If you wanted to be really thorough and handle files with `funny'
  1070.       names (embedded blanks or whatever) you'd need to use
  1071.  
  1072.  Bourne Shell:
  1073.  
  1074.      for f in *; do
  1075.        g=`expr "xxx$f" : 'xxx\(.*\)' | tr '[A-Z]' '[a-z]'`
  1076.        mv "$f" "$g"
  1077.      done
  1078.  
  1079.       The `expr' command will always print the filename, even if it
  1080.       equals `-n' or if it contains a System V escape sequence like `\c'.
  1081.  
  1082.       Some versions of "tr" require the [ and ], some don't.  It
  1083.       happens to be harmless to include them in this particular
  1084.       example; versions of tr that don't want the [] will conveniently
  1085.       think they are supposed to translate '[' to '[' and ']' to ']'.
  1086.  
  1087.       If you have the "perl" language installed, you may find this
  1088.       rename script by Larry Wall very useful.  It can be used to
  1089.       accomplish a wide variety of filename changes.
  1090.  
  1091.  #!/usr/bin/perl
  1092.  #
  1093.  # rename script examples from lwall:
  1094.  #       rename 's/\.orig$//' *.orig
  1095.  #       rename 'y/A-Z/a-z/ unless /^Make/' *
  1096.  #       rename '$_ .= ".bad"' *.f
  1097.  #       rename 'print "$_: "; s/foo/bar/ if <stdin> =~ /^y/i' *
  1098.  
  1099.  $op = shift;
  1100.  for (@ARGV) {
  1101.      $was = $_;
  1102.      eval $op;
  1103.      die $@ if $@;
  1104.      rename($was,$_) unless $was eq $_;
  1105.  }
  1106.  
  1107. ------------------------------
  1108.  
  1109. Subject: Why do I get [some strange error message] when I "rsh host command" ?
  1110. Date: Thu Mar 18 17:16:55 EST 1993
  1111.  
  1112. 2.7)  Why do I get [some strange error message] when I "rsh host command" ?
  1113.  
  1114.       (We're talking about the remote shell program "rsh" or sometimes
  1115.       "remsh" or "remote"; on some machines, there is a restricted shell
  1116.       called "rsh", which is a different thing.)
  1117.  
  1118.       If your remote account uses the C shell, the remote host will
  1119.       fire up a C shell to execute 'command' for you, and that shell
  1120.       will read your remote .cshrc file.  Perhaps your .cshrc contains
  1121.       a "stty", "biff" or some other command that isn't appropriate for
  1122.       a non-interactive shell.  The unexpected output or error message
  1123.       from these commands can screw up your rsh in odd ways.
  1124.  
  1125.       Here's an example.  Suppose you have
  1126.  
  1127.  stty erase ^H
  1128.  biff y
  1129.  
  1130.       in your .cshrc file.  You'll get some odd messages like this.
  1131.  
  1132.  % rsh some-machine date
  1133.  stty: : Can't assign requested address
  1134.  Where are you?
  1135.  Tue Oct  1 09:24:45 EST 1991
  1136.  
  1137.       You might also get similar errors when running certain "at" or
  1138.       "cron" jobs that also read your .cshrc file.
  1139.  
  1140.       Fortunately, the fix is simple.  There are, quite possibly, a
  1141.       whole *bunch* of operations in your ".cshrc" (e.g., "set
  1142.       history=N") that are simply not worth doing except in interactive
  1143.       shells.  What you do is surround them in your ".cshrc" with:
  1144.  
  1145.      if ( $?prompt ) then
  1146.       operations....
  1147.      endif
  1148.  
  1149.       and, since in a non-interactive shell "prompt" won't be set, the
  1150.       operations in question will only be done in interactive shells.
  1151.  
  1152.       You may also wish to move some commands to your .login file; if
  1153.       those commands only need to be done when a login session starts
  1154.       up (checking for new mail, unread news and so on) it's better to
  1155.       have them in the .login file.
  1156.  
  1157. ------------------------------
  1158.  
  1159. Subject: How do I ... and have that change affect my current shell?
  1160. Date: Thu Mar 18 17:16:55 EST 1993
  1161.  
  1162. 2.8)  How do I {set an environment variable, change directory} inside
  1163.       a program or shell script and have that change affect my
  1164.       current shell?
  1165.  
  1166.       In general, you can't, at least not without making special
  1167.       arrangements.  When a child process is created, it inherits a
  1168.       copy of its parent's variables (and current directory).  The
  1169.       child can change these values all it wants but the changes won't
  1170.       affect the parent shell, since the child is changing a copy of
  1171.       the original data.
  1172.  
  1173.       Some special arrangements are possible.  Your child process could
  1174.       write out the changed variables, if the parent was prepared to
  1175.       read the output and interpret it as commands to set its own
  1176.       variables.
  1177.  
  1178.       Also, shells can arrange to run other shell scripts in the
  1179.       context of the current shell, rather than in a child process, so
  1180.       that changes will affect the original shell.
  1181.  
  1182.       For instance, if you have a C shell script named "myscript":
  1183.  
  1184.  cd /very/long/path
  1185.  setenv PATH /something:/something-else
  1186.  
  1187.       or the equivalent Bourne or Korn shell script
  1188.  
  1189.  cd /very/long/path
  1190.  PATH=/something:/something-else export PATH
  1191.  
  1192.       and try to run "myscript" from your shell, your shell will fork
  1193.       and run the shell script in a subprocess.  The subprocess is also
  1194.       running the shell; when it sees the "cd" command it changes *its*
  1195.       current directory, and when it sees the "setenv" command it
  1196.       changes *its* environment, but neither has any effect on the
  1197.       current directory of the shell at which you're typing (your login
  1198.       shell, let's say).
  1199.  
  1200.       In order to get your login shell to execute the script (without
  1201.       forking) you have to use the "." command (for the Bourne or Korn
  1202.       shells) or the "source" command (for the C shell).  I.e. you type
  1203.  
  1204.  . myscript
  1205.  
  1206.       to the Bourne or Korn shells, or
  1207.  
  1208.  source myscript
  1209.  
  1210.       to the C shell.
  1211.  
  1212.       If all you are trying to do is change directory or set an
  1213.       environment variable, it will probably be simpler to use a C
  1214.       shell alias or Bourne/Korn shell function.  See the "how do I get
  1215.       the current directory into my prompt" section of this article for
  1216.       some examples.
  1217.  
  1218.       A much more detailed answer prepared by
  1219.       xtm@telelogic.se (Thomas Michanek) can be found at
  1220.       ftp.wg.omron.co.jp in /pub/unix-faq/docs/script-vs-env.
  1221.  
  1222. ------------------------------
  1223.  
  1224. Subject: How do I redirect stdout and stderr separately in csh?
  1225. From: msb@sq.com (Mark Brader)
  1226. Date: Mon, 26 Oct 1992 20:15:00 -0500
  1227.  
  1228. 2.9)  How do I redirect stdout and stderr separately in csh?
  1229.  
  1230.       In csh, you can redirect stdout with ">", or stdout and stderr
  1231.       together with ">&" but there is no direct way to redirect stderr
  1232.       only.  The best you can do is
  1233.  
  1234.  ( command >stdout_file ) >&stderr_file
  1235.  
  1236.       which runs "command" in a subshell;  stdout is redirected inside
  1237.       the subshell to stdout_file, and both stdout and stderr from the
  1238.       subshell are redirected to stderr_file, but by this point stdout
  1239.       has already been redirected so only stderr actually winds up in
  1240.       stderr_file.
  1241.  
  1242.       If what you want is to avoid redirecting stdout at all, let sh
  1243.       do it for you.
  1244.  
  1245.  sh -c 'command 2>stderr_file'
  1246.  
  1247. ------------------------------
  1248.  
  1249. Subject: How do I tell inside .cshrc if I'm a login shell?
  1250. Date: Thu Mar 18 17:16:55 EST 1993
  1251.  
  1252. 2.10) How do I tell inside .cshrc if I'm a login shell?
  1253.  
  1254.       When people ask this, they usually mean either
  1255.  
  1256.  How can I tell if it's an interactive shell?  or
  1257.  How can I tell if it's a top-level shell?
  1258.  
  1259.       You could perhaps determine if your shell truly is a login shell
  1260.       (i.e. is going to source ".login" after it is done with ".cshrc")
  1261.       by fooling around with "ps" and "$$".  Login shells generally
  1262.       have names that begin with a '-'.  If you're really interested in
  1263.       the other two questions, here's one way you can organize your
  1264.       .cshrc to find out.
  1265.  
  1266.  if (! $?CSHLEVEL) then
  1267.   #
  1268.   # This is a "top-level" shell,
  1269.   # perhaps a login shell, perhaps a shell started up by
  1270.   # 'rsh machine some-command'
  1271.   # This is where we should set PATH and anything else we
  1272.   # want to apply to every one of our shells.
  1273.   #
  1274.   setenv      CSHLEVEL        0
  1275.   set home = ~username        # just to be sure
  1276.   source ~/.env               # environment stuff we always want
  1277.  else
  1278.   #
  1279.   # This shell is a child of one of our other shells so
  1280.   # we don't need to set all the environment variables again.
  1281.   #
  1282.   set tmp = $CSHLEVEL
  1283.   @ tmp++
  1284.   setenv      CSHLEVEL        $tmp
  1285.  endif
  1286.  
  1287.  # Exit from .cshrc if not interactive, e.g. under rsh
  1288.  if (! $?prompt) exit
  1289.  
  1290.  # Here we could set the prompt or aliases that would be useful
  1291.  # for interactive shells only.
  1292.  
  1293.  source ~/.aliases
  1294.  
  1295. ------------------------------
  1296.  
  1297. Subject: How do I construct a ... matches all files except "." and ".." ?
  1298. Date: Thu Mar 18 17:16:55 EST 1993
  1299.  
  1300. 2.11) How do I construct a shell glob-pattern that matches all files
  1301.       except "." and ".." ?
  1302.  
  1303.       You'd think this would be easy.
  1304.  
  1305.       *        Matches all files that don't begin with a ".";
  1306.  
  1307.       .*      Matches all files that do begin with a ".", but
  1308.       this includes the special entries "." and "..",
  1309.       which often you don't want;
  1310.  
  1311.       .[!.]*   (Newer shells only; some shells use a "^" instead of
  1312.       the "!"; POSIX shells must accept the "!", but may
  1313.       accept a "^" as well; all portable applications shall
  1314.       not use an unquoted "^" immediately following the "[")
  1315.  
  1316.       Matches all files that begin with a "." and are
  1317.       followed by a non-"."; unfortunately this will miss
  1318.       "..foo";
  1319.  
  1320.       .??*     Matches files that begin with a "." and which are
  1321.       at least 3 characters long.  This neatly avoids
  1322.       "." and "..", but also misses ".a" .
  1323.  
  1324.       So to match all files except "." and ".." safely you have to use
  1325.       3 patterns (if you don't have filenames like ".a" you can leave
  1326.       out the first):
  1327.  
  1328.  .[!.]* .??* *
  1329.  
  1330.       Alternatively you could employ an external program or two and use
  1331.       backquote substitution.  This is pretty good:
  1332.  
  1333.       `ls -a | sed -e '/^\.$/d' -e '/^\.\.$/d'`
  1334.  
  1335.  (or `ls -A` in some Unix versions)
  1336.  
  1337.       but even it will mess up on files with newlines, IFS characters
  1338.       or wildcards in their names.
  1339.  
  1340. ------------------------------
  1341.  
  1342. Subject: How do I find the last argument in a Bourne shell script?
  1343. Date: Thu Mar 18 17:16:55 EST 1993
  1344.  
  1345. 2.12) How do I find the last argument in a Bourne shell script?
  1346.  
  1347.       Answer by:
  1348.  Martin Weitzel <@mikros.systemware.de:martin@mwtech.uucp>
  1349.  Maarten Litmaath <maart@nat.vu.nl>
  1350.  
  1351.       If you are sure the number of arguments is at most 9, you can use:
  1352.  
  1353.  eval last=\${$#}
  1354.  
  1355.       In POSIX-compatible shells it works for ANY number of arguments.
  1356.       The following works always too:
  1357.  
  1358.  for last
  1359.  do
  1360.   :
  1361.  done
  1362.  
  1363.       This can be generalized as follows:
  1364.  
  1365.  for i
  1366.  do
  1367.   third_last=$second_last
  1368.   second_last=$last
  1369.   last=$i
  1370.  done
  1371.  
  1372.       Now suppose you want to REMOVE the last argument from the list,
  1373.       or REVERSE the argument list, or ACCESS the N-th argument
  1374.       directly, whatever N may be.  Here is a basis of how to do it,
  1375.       using only built-in shell constructs, without creating subprocesses:
  1376.  
  1377.  t0= u0= rest='1 2 3 4 5 6 7 8 9' argv=
  1378.  
  1379.  for h in '' $rest
  1380.  do
  1381.   for t in "$t0" $rest
  1382.   do
  1383.    for u in $u0 $rest
  1384.    do
  1385.     case $# in
  1386.     0)
  1387.      break 3
  1388.     esac
  1389.     eval argv$h$t$u=\$1
  1390.     argv="$argv \"\$argv$h$t$u\"" # (1)
  1391.     shift
  1392.    done
  1393.    u0=0
  1394.   done
  1395.   t0=0
  1396.  done
  1397.  
  1398.  # now restore the arguments
  1399.  eval set x "$argv"     # (2)
  1400.  shift
  1401.  
  1402.       This example works for the first 999 arguments.  Enough?
  1403.       Take a good look at the lines marked (1) and (2) and convince
  1404.       yourself that the original arguments are restored indeed, no
  1405.       matter what funny characters they contain!
  1406.  
  1407.       To find the N-th argument now you can use this:
  1408.  
  1409.  eval argN=\$argv$N
  1410.  
  1411.       To reverse the arguments the line marked (1) must be changed to:
  1412.  
  1413.  argv="\"\$argv$h$t$u\" $argv"
  1414.  
  1415.       How to remove the last argument is left as an exercise.
  1416.  
  1417.       If you allow subprocesses as well, possibly executing nonbuilt-in
  1418.       commands, the `argvN' variables can be set up more easily:
  1419.  
  1420.  N=1
  1421.  
  1422.  for i
  1423.  do
  1424.   eval argv$N=\$i
  1425.   N=`expr $N + 1`
  1426.  done
  1427.  
  1428.       To reverse the arguments there is still a simpler method, that
  1429.       even does not create subprocesses.  This approach can also be
  1430.       taken if you want to delete e.g. the last argument, but in that
  1431.       case you cannot refer directly to the N-th argument any more,
  1432.       because the `argvN' variables are set up in reverse order:
  1433.  
  1434.  argv=
  1435.  
  1436.  for i
  1437.  do
  1438.   eval argv$#=\$i
  1439.   argv="\"\$argv$#\" $argv"
  1440.   shift
  1441.  done
  1442.  
  1443.  eval set x "$argv"
  1444.  shift
  1445.  
  1446. ------------------------------
  1447.  
  1448. Subject: What's wrong with having '.' in your $PATH ?
  1449. Date: Thu Mar 18 17:16:55 EST 1993
  1450.  
  1451. 2.13) What's wrong with having '.' in your $PATH ?
  1452.  
  1453.       A bit of background: the PATH environment variable is a list of
  1454.       directories separated by colons.  When you type a command name
  1455.       without giving an explicit path (e.g. you type "ls", rather than
  1456.       "/bin/ls") your shell searches each directory in the PATH list in
  1457.       order, looking for an executable file by that name, and the shell
  1458.       will run the first matching program it finds.
  1459.  
  1460.       One of the directories in the PATH list can be the current
  1461.       directory "." .  It is also permissible to use an empty directory
  1462.       name in the PATH list to indicate the current directory.  Both of
  1463.       these are equivalent
  1464.  
  1465.       for csh users:
  1466.  
  1467.  setenv PATH :/usr/ucb:/bin:/usr/bin
  1468.  setenv PATH .:/usr/ucb:/bin:/usr/bin
  1469.  
  1470.       for sh or ksh users
  1471.  
  1472.  PATH=:/usr/ucb:/bin:/usr/bin export PATH
  1473.  PATH=.:/usr/ucb:/bin:/usr/bin export PATH
  1474.  
  1475.       Having "." somewhere in the PATH is convenient - you can type
  1476.       "a.out" instead of "./a.out" to run programs in the current
  1477.       directory.  But there's a catch.
  1478.  
  1479.       Consider what happens in the case  where "." is the first entry
  1480.       in the PATH.  Suppose your current directory is a publically-
  1481.       writable one, such as "/tmp".  If there just happens to be a
  1482.       program named "/tmp/ls" left there by some other user, and you
  1483.       type "ls" (intending, of course, to run the normal "/bin/ls"
  1484.       program), your shell will instead run "./ls", the other user's
  1485.       program.  Needless to say, the results of running an unknown
  1486.       program like this might surprise you.
  1487.  
  1488.       It's slightly better to have "." at the end of the PATH:
  1489.  
  1490.  setenv PATH /usr/ucb:/bin:/usr/bin:.
  1491.  
  1492.       Now if you're in /tmp and you type "ls", the shell will
  1493.       search /usr/ucb, /bin and /usr/bin for a program named
  1494.       "ls" before it gets around to looking in ".", and there
  1495.       is less risk of inadvertently running some other user's
  1496.       "ls" program.  This isn't 100% secure though - if you're
  1497.       a clumsy typist and some day type "sl -l" instead of "ls -l",
  1498.       you run the risk of running "./sl", if there is one.
  1499.       Some "clever" programmer could anticipate common typing
  1500.       mistakes and leave programs by those names scattered
  1501.       throughout public directories.  Beware.
  1502.  
  1503.       Many seasoned Unix users get by just fine without having
  1504.       "." in the PATH at all:
  1505.  
  1506.  setenv PATH /usr/ucb:/bin:/usr/bin
  1507.  
  1508.       If you do this, you'll need to type "./program" instead
  1509.       of "program" to run programs in the current directory, but
  1510.       the increase in security is probably worth it.
  1511.  
  1512. ------------------------------
  1513.  
  1514. Subject: How do I ring the terminal bell during a shell script?
  1515. From: uwe@mpi-sb.mpg.de (Uwe Waldmann)
  1516. Date: Fri, 30 Apr 93 16:33:00 +0200
  1517.  
  1518. 2.9)  How do I ring the terminal bell during a shell script?
  1519.  
  1520.       The answer depends on your Unix version (or rather on the kind of
  1521.       "echo" program that is available on your machine).
  1522.  
  1523.       A BSD-like "echo" uses the "-n" option for suppressing the final
  1524.       newline and does not understand the octal \nnn notation.  Thus
  1525.       the command is
  1526.  
  1527.         echo -n '^G'
  1528.  
  1529.       where ^G means a _literal_ BEL-character (you can produce this in
  1530.       emacs using "Ctrl-Q Ctrl-G" and in vi using "Ctrl-V Ctrl-G").
  1531.  
  1532.       A SysV-like "echo" understands the \nnn notation and uses \c to
  1533.       suppress the final newline, so the answer is:
  1534.  
  1535.         echo '\007\c'
  1536.  
  1537. ------------------------------
  1538.  
  1539. Subject: Why can't I use "talk" to talk with my friend on machine X?
  1540. From: tmatimar@isgtec.com (Ted Timar)
  1541. Date: Thu Mar 18 17:16:55 EST 1993
  1542.  
  1543. 2.15) Why can't I use "talk" to talk with my friend on machine X?
  1544.  
  1545.       Unix has three common "talk" programs, none of which can talk with
  1546.       any of the others.  The "old" talk accounts for the first two types.
  1547.       This version (often called otalk) did not take "endian" order into
  1548.       account when talking to other machines.  As a consequence, the Vax
  1549.       version of otalk cannot talk with the Sun version of otalk.
  1550.       These versions of talk use port 517.
  1551.  
  1552.       Around 1987, most vendors (except Sun, who took 6 years longer than
  1553.       any of their competitors) standardized on a new talk (often called
  1554.       ntalk) which knows about network byte order.  This talk works between
  1555.       all machines that have it.  This version of talk uses port 518.
  1556.  
  1557.       There are now a few talk programs that speak both ntalk and one
  1558.       version of otalk.  The most common of these is called "ytalk".
  1559.  
  1560. ------------------------------
  1561.  
  1562. End of unix/faq Digest part 2 of 7
  1563. **********************************
  1564.  
  1565. --
  1566. Ted Timar - tmatimar@isgtec.com
  1567. ISG Technologies Inc., 6509 Airport Road, Mississauga, Ontario, Canada L4V 1S7
  1568.  
  1569.  
  1570. -------------------------------------------------------------------------------
  1571. Area # 2120  news.answers           05-30-94 04:34      Message # 13347
  1572. From    : Ted Timar
  1573. To      : ALL                                           
  1574. Subj    : Unix - Frequently Asked
  1575.  
  1576.  @FROM   :tmatimar@isgtec.com                                          
  1577.  @SUBJECT:Unix - Frequently Asked Questions (3/7) [Frequent posting]   
  1578.  @PACKOUT:05-31-9440,3193382879                                        
  1579. Message-ID: <unix-faq/faq/part3_770286840@rtfm.mit.edu>
  1580. Newsgroups: comp.unix.questions,comp.unix.shell,comp.answers,news.answers
  1581. Organization: ISG Technologies, Inc
  1582.  
  1583. Archive-name: unix-faq/faq/part3
  1584. Version: $Id: part3,v 2.5 1994/04/28 19:25:03 tmatimar Exp $
  1585.  
  1586. These seven articles contain the answers to some Frequently Asked
  1587. Questions often seen in comp.unix.questions and comp.unix.shell.
  1588. Please don't ask these questions again, they've been answered plenty
  1589. of times already - and please don't flame someone just because they may
  1590. not have read this particular posting.  Thank you.
  1591.  
  1592. This collection of documents is Copyright (c) 1994, Ted Timar.
  1593. All rights reserved.  Permission to distribute the collection is
  1594. hereby granted providing that distribution is electronic, no money
  1595. is involved, reasonable attempts are made to use the latest version
  1596. and all credits and this copyright notice are maintained.
  1597. Other requests for distribution will be considered.
  1598.  
  1599. All information here has been contributed with good intentions, but
  1600. none of it is guaranteed either by the contributors or myself to be
  1601. accurate.  The users of this information take all responsibility for
  1602. any damage that may occur.
  1603.  
  1604. Many FAQs, including this one, are available on the archive site
  1605. rtfm.mit.edu in the directory pub/usenet/news.answers.
  1606. The name under which a FAQ is archived appears in the "Archive-Name:"
  1607. line at the top of the article.  This FAQ is archived as
  1608. "unix-faq/faq/part[1-7]".
  1609.  
  1610. These articles are divided approximately as follows:
  1611.  
  1612.       1.*) General questions.
  1613.       2.*) Relatively basic questions, likely to be asked by beginners.
  1614.       3.*) Intermediate questions.
  1615.       4.*) Advanced questions, likely to be asked by people who thought
  1616.     they already knew all of the answers.
  1617.       5.*) Questions pertaining to the various shells, and the differences.
  1618.       6.*) An overview of Unix variants.
  1619.       7.*) An comparison of configuration management systems (RCS, SCCS).
  1620.  
  1621. This article includes answers to:
  1622.  
  1623.       3.1)  How do I find the creation time of a file?
  1624.       3.2)  How do I use "rsh" without having the rsh hang around
  1625.               until the remote command has completed?
  1626.       3.3)  How do I truncate a file?
  1627.       3.4)  Why doesn't find's "{}" symbol do what I want?
  1628.       3.5)  How do I set the permissions on a symbolic link?
  1629.       3.6)  How do I "undelete" a file?
  1630.       3.7)  How can a process detect if it's running in the background?
  1631.       3.8)  Why doesn't redirecting a loop work as intended?  (Bourne shell)
  1632.       3.9)  How do I run 'passwd', 'ftp', 'telnet', 'tip' and other
  1633. interactive
  1634.               programs from a shell script or in the background?
  1635.       3.10) How do I find the process ID of a program with a particular
  1636.             name from inside a shell script or C program?
  1637.       3.11) How do I check the exit status of a remote command
  1638.             executed via "rsh" ?
  1639.       3.12) Is it possible to pass shell variable settings into an awk
  1640. program?
  1641.       3.13) How do I get rid of zombie processes that persevere?
  1642.       3.14) How do I get lines from a pipe as they are written instead of
  1643.             only in larger blocks.
  1644.  
  1645. If you're looking for the answer to, say, question 3.5, and want to skip
  1646. everything else, you can search ahead for the regular expression "^3.5)".
  1647.  
  1648. While these are all legitimate questions, they seem to crop up in
  1649. comp.unix.questions or comp.unix.shell on an annual basis, usually
  1650. followed by plenty of replies (only some of which are correct) and then
  1651. a period of griping about how the same questions keep coming up.  You
  1652. may also like to read the monthly article "Answers to Frequently Asked
  1653. Questions" in the newsgroup "news.announce.newusers", which will tell
  1654. you what "UNIX" stands for.
  1655.  
  1656. With the variety of Unix systems in the world, it's hard to guarantee
  1657. that these answers will work everywhere.  Read your local manual pages
  1658. before trying anything suggested here.  If you have suggestions or
  1659. corrections for any of these answers, please send them to to
  1660. tmatimar@isgtec.com.
  1661.  
  1662. ----------------------------------------------------------------------
  1663.  
  1664. Subject: How do I find the creation time of a file?
  1665. Date: Thu Mar 18 17:16:55 EST 1993
  1666.  
  1667. 3.1)  How do I find the creation time of a file?
  1668.  
  1669.       You can't - it isn't stored anywhere.  Files have a last-modified
  1670.       time (shown by "ls -l"), a last-accessed time (shown by "ls -lu")
  1671.       and an inode change time (shown by "ls -lc"). The latter is often
  1672.       referred to as the "creation time" - even in some man pages -
  1673.       but that's wrong; it's also set by such operations as mv, ln,
  1674.       chmod, chown and chgrp.
  1675.  
  1676.       The man page for "stat(2)" discusses this.
  1677.  
  1678. ------------------------------
  1679.  
  1680. Subject: How do I use "rsh" without having the rsh hang around ... ?
  1681. Date: Thu Mar 18 17:16:55 EST 1993
  1682.  
  1683. 3.2)  How do I use "rsh" without having the rsh hang around until the
  1684.       remote command has completed?
  1685.  
  1686.       (See note in question 2.7 about what "rsh" we're talking about.)
  1687.  
  1688.       The obvious answers fail:
  1689.            rsh machine command &
  1690.       or      rsh machine 'command &'
  1691.  
  1692.       For instance, try doing   rsh machine 'sleep 60 &' and you'll see
  1693.       that the 'rsh' won't exit right away.  It will wait 60 seconds
  1694.       until the remote 'sleep' command finishes, even though that
  1695.       command was started in the background on the remote machine.  So
  1696.       how do you get the 'rsh' to exit immediately after the 'sleep' is
  1697.       started?
  1698.  
  1699.       The solution - if you use csh on the remote machine:
  1700.  
  1701.      rsh machine -n 'command >&/dev/null </dev/null &'
  1702.  
  1703.       If you use sh on the remote machine:
  1704.  
  1705.      rsh machine -n 'command >/dev/null 2>&1 </dev/null &'
  1706.  
  1707.       Why?  "-n" attaches rsh's stdin to /dev/null so you could run the
  1708.       complete rsh command in the background on the LOCAL machine.
  1709.       Thus "-n" is equivalent to another specific "< /dev/null".
  1710.       Furthermore, the input/output redirections on the REMOTE machine
  1711.       (inside the single quotes) ensure that rsh thinks the session can
  1712.       be terminated (there's no data flow any more.)
  1713.  
  1714.       Note: The file that you redirect to/from on the remote machine
  1715.       doesn't have to be /dev/null; any ordinary file will do.
  1716.  
  1717.       In many cases, various parts of these complicated commands
  1718.       aren't necessary.
  1719.  
  1720. ------------------------------
  1721.  
  1722. Subject: How do I truncate a file?
  1723. Date: Thu Mar 18 17:16:55 EST 1993
  1724.  
  1725. 3.3)  How do I truncate a file?
  1726.  
  1727.       The BSD function ftruncate() sets the length of a file.  Xenix -
  1728.       and therefore SysV r3.2 and later - has the chsize() system
  1729.       call.  For other systems, the only kind of truncation you can do
  1730.       is truncation to length zero with creat() or open(..., O_TRUNC).
  1731.  
  1732. ------------------------------
  1733.  
  1734. Subject: Why doesn't find's "{}" symbol do what I want?
  1735. Date: Thu Mar 18 17:16:55 EST 1993
  1736.  
  1737. 3.4)  Why doesn't find's "{}" symbol do what I want?
  1738.  
  1739.       "find" has a -exec option that will execute a particular command
  1740.       on all the selected files. Find will replace any "{}" it sees
  1741.       with the name of the file currently under consideration.
  1742.  
  1743.       So, some day you might try to use "find" to run a command on
  1744.       every file, one directory at a time.  You might try this:
  1745.  
  1746.  find /path -type d -exec command {}/\* \;
  1747.  
  1748.       hoping that find will execute, in turn
  1749.  
  1750.  command directory1/*
  1751.  command directory2/*
  1752.  ...
  1753.  
  1754.       Unfortunately, find only expands the "{}" token when it appears
  1755.       by itself.  Find will leave anything else like "{}/*" alone, so
  1756.       instead of doing what you want, it will do
  1757.  
  1758.  command {}/*
  1759.  command {}/*
  1760.  ...
  1761.  
  1762.       once for each directory.  This might be a bug, it might be a
  1763.       feature, but we're stuck with the current behaviour.
  1764.  
  1765.       So how do you get around this?  One way would be to write a
  1766.       trivial little shell script, let's say "./doit", that consists of
  1767.  
  1768.  command "$1"/*
  1769.  
  1770.       You could then use
  1771.  
  1772.  find /path -type d -exec ./doit {} \;
  1773.  
  1774.       Or if you want to avoid the "./doit" shell script, you can use
  1775.  
  1776.  find /path -type d -exec sh -c 'command $0/*' {} \;
  1777.  
  1778.       (This works because within the 'command' of "sh -c 'command' A B C ...",
  1779.        $0 expands to A, $1 to B, and so on.)
  1780.  
  1781.       or you can use the construct-a-command-with-sed trick
  1782.  
  1783.  find /path -type d -print | sed 's:.*:command &/*:' | sh
  1784.  
  1785.       If all you're trying to do is cut down on the number of times
  1786.       that "command" is executed, you should see if your system has the
  1787.       "xargs" command.  Xargs reads arguments one line at a time from
  1788.       the standard input and assembles as many of them as will fit into
  1789.       one command line.  You could use
  1790.  
  1791.  find /path -print | xargs command
  1792.  
  1793.       which would result in one or more executions of
  1794.  
  1795.  command file1 file2 file3 file4 dir1/file1 dir1/file2
  1796.  
  1797.       Unfortunately this is not a perfectly robust or secure solution.
  1798.       Xargs expects its input lines to be terminated with newlines, so
  1799.       it will be confused by files with odd characters such as newlines
  1800.       in their names.
  1801.  
  1802. ------------------------------
  1803.  
  1804. Subject: How do I set the permissions on a symbolic link?
  1805. Date: Thu Mar 18 17:16:55 EST 1993
  1806.  
  1807. 3.5)  How do I set the permissions on a symbolic link?
  1808.  
  1809.       Permissions on a symbolic link don't really mean anything.  The
  1810.       only permissions that count are the permissions on the file that
  1811.       the link points to.
  1812.  
  1813. ------------------------------
  1814.  
  1815. Subject: How do I "undelete" a file?
  1816. Date: Thu Mar 18 17:16:55 EST 1993
  1817.  
  1818. 3.6)  How do I "undelete" a file?
  1819.  
  1820.       Someday, you are going to accidentally type something like
  1821.       "rm * .foo", and find you just deleted "*" instead of "*.foo".
  1822.       Consider it a rite of passage.
  1823.  
  1824.       Of course, any decent systems administrator should be doing
  1825.       regular backups.  Check with your sysadmin to see if a recent
  1826.       backup copy of your file is available.  But if it isn't, read
  1827.       on.
  1828.  
  1829.       For all intents and purposes, when you delete a file with "rm" it
  1830.       is gone.  Once you "rm" a file, the system totally forgets which
  1831.       blocks scattered around the disk were part of your file.  Even
  1832.       worse, the blocks from the file you just deleted are going to be
  1833.       the first ones taken and scribbled upon when the system needs
  1834.       more disk space.  However, never say never.  It is theoretically
  1835.       possible *if* you shut down the system immediately after the "rm"
  1836.       to recover portions of the data.  However, you had better have a
  1837.       very wizardly type person at hand with hours or days to spare to
  1838.       get it all back.
  1839.  
  1840.       Your first reaction when you "rm" a file by mistake is why not
  1841.       make a shell alias or procedure which changes "rm" to move files
  1842.       into a trash bin rather than delete them?  That way you can
  1843.       recover them if you make a mistake, and periodically clean out
  1844.       your trash bin.  Two points:  first, this is generally accepted
  1845.       as a *bad* idea.  You will become dependent upon this behaviour
  1846.       of "rm", and you will find yourself someday on a normal system
  1847.       where "rm" is really "rm", and you will get yourself in trouble.
  1848.       Second, you will eventually find that the hassle of dealing with
  1849.       the disk space and time involved in maintaining the trash bin, it
  1850.       might be easier just to be a bit more careful with "rm".  For
  1851.       starters, you should look up the "-i" option to "rm" in your
  1852.       manual.
  1853.  
  1854.       If you are still undaunted, then here is a possible simple
  1855.       answer.  You can create yourself a "can" command which moves
  1856.       files into a trashcan directory. In csh(1) you can place the
  1857.       following commands in the ".login" file in your home directory:
  1858.  
  1859.  alias can 'mv \!* ~/.trashcan'    # junk file(s) to trashcan
  1860.  alias mtcan 'rm -f ~/.trashcan/*'    # irretrievably empty trash
  1861.  if ( ! -d ~/.trashcan ) mkdir ~/.trashcan  # ensure trashcan exists
  1862.  
  1863.       You might also want to put a:
  1864.  
  1865.  rm -f ~/.trashcan/*
  1866.  
  1867.       in the ".logout" file in your home directory to automatically
  1868.       empty the trash when you log out.  (sh and ksh versions are left
  1869.       as an exercise for the reader.)
  1870.  
  1871.       MIT's Project Athena has produced a comprehensive
  1872.       delete/undelete/expunge/purge package, which can serve as a
  1873.       complete replacement for rm which allows file recovery.  This
  1874.       package was posted to comp.sources.misc (volume 17, issue
  1875.       023-026)
  1876.  
  1877. ------------------------------
  1878.  
  1879. Subject: How can a process detect if it's running in the background?
  1880. Date: Thu Mar 18 17:16:55 EST 1993
  1881.  
  1882. 3.7)  How can a process detect if it's running in the background?
  1883.  
  1884.       First of all: do you want to know if you're running in the
  1885.       background, or if you're running interactively? If you're
  1886.       deciding whether or not you should print prompts and the like,
  1887.       that's probably a better criterion. Check if standard input
  1888.       is a terminal:
  1889.  
  1890.      sh: if [ -t 0 ]; then ... fi
  1891.      C: if(isatty(0)) { ... }
  1892.  
  1893.       In general, you can't tell if you're running in the background.
  1894.       The fundamental problem is that different shells and different
  1895.       versions of UNIX have different notions of what "foreground" and
  1896.       "background" mean - and on the most common type of system with a
  1897.       better-defined notion of what they mean, programs can be moved
  1898.       arbitrarily between foreground and background!
  1899.  
  1900.       UNIX systems without job control typically put a process into the
  1901.       background by ignoring SIGINT and SIGQUIT and redirecting the
  1902.       standard input to "/dev/null"; this is done by the shell.
  1903.  
  1904.       Shells that support job control, on UNIX systems that support job
  1905.       control, put a process into the background by giving it a process
  1906.       group ID different from the process group to which the terminal
  1907.       belongs.  They move it back into the foreground by setting the
  1908.       terminal's process group ID to that of the process.  Shells that
  1909.       do *not* support job control, on UNIX systems that support job
  1910.       control, typically do what shells do on systems that don't
  1911.       support job control.
  1912.  
  1913. ------------------------------
  1914.  
  1915. Subject: Why doesn't redirecting a loop work as intended?  (Bourne shell)
  1916. Date: Thu Mar 18 17:16:55 EST 1993
  1917.  
  1918. 3.8)  Why doesn't redirecting a loop work as intended?  (Bourne shell)
  1919.  
  1920.       Take the following example:
  1921.  
  1922.  foo=bar
  1923.  
  1924.  while read line
  1925.  do
  1926.   # do something with $line
  1927.   foo=bletch
  1928.  done < /etc/passwd
  1929.  
  1930.  echo "foo is now: $foo"
  1931.  
  1932.       Despite the assignment ``foo=bletch'' this will print
  1933.       ``foo is now: bar'' in many implementations of the Bourne shell.
  1934.       Why?  Because of the following, often undocumented, feature of
  1935.       historic Bourne shells: redirecting a control structure (such as
  1936.       a loop, or an ``if'' statement) causes a subshell to be created,
  1937.       in which the structure is executed; variables set in that
  1938.       subshell (like the ``foo=bletch'' assignment) don't affect the
  1939.       current shell, of course.
  1940.  
  1941.       The POSIX 1003.2 Shell and Tools Interface standardization
  1942.       committee forbids the behaviour described above, i.e. in P1003.2
  1943.       conformant Bourne shells the example will print ``foo is now:
  1944.       bletch''.
  1945.  
  1946.       In historic (and P1003.2 conformant) implementations you can use
  1947.       the following `trick' to get around the redirection problem:
  1948.  
  1949.  foo=bar
  1950.  
  1951.  # make file descriptor 9 a duplicate of file descriptor 0 (stdin);
  1952.  # then connect stdin to /etc/passwd; the original stdin is now
  1953.  # `remembered' in file descriptor 9; see dup(2) and sh(1)
  1954.  exec 9<&0 < /etc/passwd
  1955.  
  1956.  while read line
  1957.  do
  1958.   # do something with $line
  1959.   foo=bletch
  1960.  done
  1961.  
  1962.  # make stdin a duplicate of file descriptor 9, i.e. reconnect
  1963.  # it to the original stdin; then close file descriptor 9
  1964.  exec 0<&9 9<&-
  1965.  
  1966.  echo "foo is now: $foo"
  1967.  
  1968.       This should always print ``foo is now: bletch''.
  1969.       Right, take the next example:
  1970.  
  1971.  foo=bar
  1972.  
  1973.  echo bletch | read foo
  1974.  
  1975.  echo "foo is now: $foo"
  1976.  
  1977.       This will print ``foo is now: bar'' in many implementations,
  1978.       ``foo is now: bletch'' in some others.  Why?  Generally each part
  1979.       of a pipeline is run in a different subshell; in some
  1980.       implementations though, the last command in the pipeline is made
  1981.       an exception: if it is a builtin command like ``read'', the
  1982.       current shell will execute it, else another subshell is created.
  1983.  
  1984.       POSIX 1003.2 allows both behaviours so portable scripts cannot
  1985.       depend on any of them.
  1986.  
  1987. ------------------------------
  1988.  
  1989. Subject: How do I run ... interactive programs from a shell script ... ?
  1990. Date: Thu Mar 18 17:16:55 EST 1993
  1991.  
  1992. 3.9)  How do I run 'passwd', 'ftp', 'telnet', 'tip' and other interactive
  1993.       programs from a shell script or in the background?
  1994.  
  1995.       These programs expect a terminal interface.  Shells makes no
  1996.       special provisions to provide one.  Hence, such programs cannot
  1997.       be automated in shell scripts.
  1998.  
  1999.       The 'expect' program provides a programmable terminal interface
  2000.       for automating interaction with such programs.  The following
  2001.       expect script is an example of a non-interactive version of
  2002.       passwd(1).
  2003.  
  2004.  # username is passed as 1st arg, password as 2nd
  2005.  set password [index $argv 2]
  2006.  spawn passwd [index $argv 1]
  2007.  expect "*password:"
  2008.  send "$password\r"
  2009.  expect "*password:"
  2010.  send "$password\r"
  2011.  expect eof
  2012.  
  2013.       expect can partially automate interaction which is especially
  2014.       useful for telnet, rlogin, debuggers or other programs that have
  2015.       no built-in command language.  The distribution provides an
  2016.       example script to rerun rogue until a good starting configuration
  2017.       appears.  Then, control is given back to the user to enjoy the game.
  2018.  
  2019.       Fortunately some programs have been written to manage the
  2020.       connection to a pseudo-tty so that you can run these sorts of
  2021.       programs in a script.
  2022.  
  2023.       To get expect, email "send pub/expect/expect.shar.Z" to
  2024.       library@cme.nist.gov or anonymous ftp same from
  2025.       ftp.cme.nist.gov.
  2026.  
  2027.       Another solution is provided by the pty 4.0 program, which runs a
  2028.       program under a pseudo-tty session and was posted to
  2029.       comp.sources.unix, volume 25.  A pty-based solution using named
  2030.       pipes to do the same as the above might look like this:
  2031.  
  2032.  #!/bin/sh
  2033.  /etc/mknod out.$$ p; exec 2>&1
  2034.  ( exec 4<out.$$; rm -f out.$$
  2035.  <&4 waitfor 'password:'
  2036.      echo "$2"
  2037.  <&4 waitfor 'password:'
  2038.      echo "$2"
  2039.  <&4 cat >/dev/null
  2040.  ) | ( pty passwd "$1" >out.$$ )
  2041.  
  2042.       Here, 'waitfor' is a simple C program that searches for
  2043.       its argument in the input, character by character.
  2044.  
  2045.       A simpler pty solution (which has the drawback of not
  2046.       synchronizing properly with the passwd program) is
  2047.  
  2048.  #!/bin/sh
  2049.  ( sleep 5; echo "$2"; sleep 5; echo "$2") | pty passwd "$1"
  2050.  
  2051. ------------------------------
  2052.  
  2053. Subject: How do I find the process ID of a program with a particular name ...
  2054. ?
  2055. Date: Thu Mar 18 17:16:55 EST 1993
  2056.  
  2057. 3.10) How do I find the process ID of a program with a particular name
  2058.       from inside a shell script or C program?
  2059.  
  2060.       In a shell script:
  2061.  
  2062.       There is no utility specifically designed to map between program
  2063.       names and process IDs.  Furthermore, such mappings are often
  2064.       unreliable, since it's possible for more than one process to have
  2065.       the same name, and since it's possible for a process to change
  2066.       its name once it starts running.  However, a pipeline like this
  2067.       can often be used to get a list of processes (owned by you) with
  2068.       a particular name:
  2069.  
  2070.      ps ux | awk '/name/ && !/awk/ {print $2}'
  2071.  
  2072.       You replace "name" with the name of the process for which you are
  2073.       searching.
  2074.  
  2075.       The general idea is to parse the output of ps, using awk or grep
  2076.       or other utilities, to search for the lines with the specified
  2077.       name on them, and print the PID's for those lines.  Note that the
  2078.       "!/awk/" above prevents the awk process for being listed.
  2079.  
  2080.       You may have to change the arguments to ps, depending on what
  2081.       kind of Unix you are using.
  2082.  
  2083.       In a C program:
  2084.  
  2085.       Just as there is no utility specifically designed to map between
  2086.       program names and process IDs, there are no (portable) C library
  2087.       functions to do it either.
  2088.  
  2089.       However, some vendors provide functions for reading Kernel
  2090.       memory; for example, Sun provides the "kvm_" functions, and Data
  2091.       General provides the "dg_" functions.  It may be possible for any
  2092.       user to use these, or they may only be useable by the super-user
  2093.       (or a user in group "kmem") if read-access to kernel memory on
  2094.       your system is restricted.  Furthermore, these functions are
  2095.       often not documented or documented badly, and might change from
  2096.       release to release.
  2097.  
  2098.       Some vendors provide a "/proc" filesystem, which appears as a
  2099.       directory with a bunch of filenames in it.  Each filename is a
  2100.       number, corresponding to a process ID, and you can open the file
  2101.       and read it to get information about the process.  Once again,
  2102.       access to this may be restricted, and the interface to it may
  2103.       change from system to system.
  2104.  
  2105.       If you can't use vendor-specific library functions, and you
  2106.       don't have /proc, and you still want to do this completely
  2107.       in C, you
  2108.       are going to have to do the rummaging through kernel memory
  2109.       yourself.  For a good example of how to do this on many systems,
  2110.       see the sources to "ofiles", available in the comp.sources.unix
  2111.       archives.  (A package named "kstuff" to help with kernel
  2112.       rummaging was posted to alt.sources in May 1991 and is also
  2113.       available via anonymous ftp as
  2114.       usenet/alt.sources/articles/{329{6,7,8,9},330{0,1}}.Z from
  2115.       wuarchive.wustl.edu.)
  2116.  
  2117. ------------------------------
  2118.  
  2119. Subject: How do I check the exit status of a remote command executed via
  2120. "rsh"?
  2121. Date: Thu Mar 18 17:16:55 EST 1993
  2122.  
  2123. 3.11) How do I check the exit status of a remote command
  2124.       executed via "rsh" ?
  2125.  
  2126.       This doesn't work:
  2127.  
  2128.  rsh some-machine some-crummy-command || echo "Command failed"
  2129.  
  2130.       The exit status of 'rsh' is 0 (success) if the rsh program
  2131.       itself completed successfully, which probably isn't what
  2132.       you wanted.
  2133.  
  2134.       If you want to check on the exit status of the remote program,
  2135.       you can try using Maarten Litmaath's 'ersh' script, which was
  2136.       posted to alt.sources in January, 1991.  ersh is a shell script
  2137.       that calls rsh, arranges for the remote machine to echo the
  2138.       status of the command after it completes, and exits with that
  2139.       status.
  2140.  
  2141. ------------------------------
  2142.  
  2143. Subject: Is it possible to pass shell variable settings into an awk program?
  2144. Date: Thu Mar 18 17:16:55 EST 1993
  2145.  
  2146. 3.12) Is it possible to pass shell variable settings into an awk program?
  2147.  
  2148.       There are two different ways to do this.  The first involves
  2149.       simply expanding the variable where it is needed in the program.
  2150.       For example, to get a list of all ttys you're using:
  2151.  
  2152.  who | awk '/^'"$USER"'/ { print $2 }'    (1)
  2153.  
  2154.       Single quotes are usually used to enclose awk programs because
  2155.       the character '$' is often used in them, and '$' will be
  2156.       interpreted by the shell if enclosed inside double quotes, but
  2157.       not if enclosed inside single quotes.  In this case, we *want*
  2158.       the '$' in "$USER" to be interpreted by the shell, so we close
  2159.       the single quotes and then put the "$USER" inside double quotes.
  2160.       Note that there are no spaces in any of that, so the shell will
  2161.       see it all as one argument.  Note, further, that the double
  2162.       quotes probably aren't necessary in this particular case (i.e. we
  2163.       could have done
  2164.  
  2165.  who | awk '/^'$USER'/ { print $2 }'    (2)
  2166.  
  2167.       ), but they should be included nevertheless because they are
  2168.       necessary when the shell variable in question contains special
  2169.       characters or spaces.
  2170.  
  2171.       The second way to pass variable settings into awk is to use an
  2172.       often undocumented feature of awk which allows variable settings
  2173.       to be specified as "fake file names" on the command line.  For
  2174.       example:
  2175.  
  2176.  who | awk '$1 == user { print $2 }' user="$USER" -  (3)
  2177.  
  2178.       Variable settings take effect when they are encountered on the
  2179.       command line, so, for example, you could instruct awk on how to
  2180.       behave for different files using this technique.  For example:
  2181.  
  2182.  awk '{ program that depends on s }' s=1 file1 s=0 file2  (4)
  2183.  
  2184.       Note that some versions of awk will cause variable settings
  2185.       encountered before any real filenames to take effect before the
  2186.       BEGIN block is executed, but some won't so neither way should be
  2187.       relied upon.
  2188.  
  2189.       Note, further, that when you specify a variable setting, awk
  2190.       won't automatically read from stdin if no real files are
  2191.       specified, so you need to add a "-" argument to the end of your
  2192.       command, as I did at (3) above.
  2193.  
  2194. ------------------------------
  2195.  
  2196. Subject: How do I get rid of zombie processes that persevere?
  2197. From: jik@rtfm.MIT.Edu (Jonathan I. Kamens)
  2198. From: casper@fwi.uva.nl (Casper Dik)
  2199. Date: Thu, 09 Sep 93 16:39:58 +0200
  2200.  
  2201. 3.13) How do I get rid of zombie processes that persevere?
  2202.  
  2203.       Unfortunately, it's impossible to generalize how the death of
  2204.       child processes should behave, because the exact mechanism varies
  2205.       over the various flavors of Unix.
  2206.  
  2207.       First of all, by default, you have to do a wait() for child
  2208.       processes under ALL flavors of Unix.  That is, there is no flavor
  2209.       of Unix that I know of that will automatically flush child
  2210.       processes that exit, even if you don't do anything to tell it to
  2211.       do so.
  2212.  
  2213.       Second, under some SysV-derived systems, if you do
  2214.       "signal(SIGCHLD, SIG_IGN)" (well, actually, it may be SIGCLD
  2215.       instead of SIGCHLD, but most of the newer SysV systems have
  2216.       "#define SIGCHLD SIGCLD" in the header files), then child
  2217.       processes will be cleaned up automatically, with no further
  2218.       effort in your part.  The best way to find out if it works at
  2219.       your site is to try it, although if you are trying to write
  2220.       portable code, it's a bad idea to rely on this in any case.
  2221.       Unfortunately, POSIX doesn't allow you to do this; the behavior
  2222.       of setting the SIGCHLD to SIG_IGN under POSIX is undefined, so
  2223.       you can't do it if your program is supposed to be
  2224.       POSIX-compliant.
  2225.  
  2226.       So, what's the POSIX way? As mentioned earlier, you must
  2227.       install a signal handler and wait. Under POSIX signal handlers
  2228.       are installed with sigaction. Since you are not interested in
  2229.       ``stopped'' children, only in terminated children, add SA_NOCLDSTOP
  2230.       to sa_flags.  Waiting without blocking is done with waitpid().
  2231.       The first argument to waitpid should be -1 (wait for any pid),
  2232.       the third should be WNOHANG. This is the most portable way
  2233.       and is likely to become more portable in future.
  2234.  
  2235.       If your systems doesn't support POSIX, there's a number of ways.
  2236.       The easiest way is signal(SIGCHLD, SIG_IGN), if it works.
  2237.       If SIG_IGN cannot be used to force automatic clean-up, then you've
  2238.       got to write a signal handler to do it.  It isn't easy at all to
  2239.       write a signal handler that does things right on all flavors of
  2240.       Unix, because of the following inconsistencies:
  2241.  
  2242.       On some flavors of Unix, the SIGCHLD signal handler is called if
  2243.       one *or more* children have died.  This means that if your signal
  2244.       handler only does one wait() call, then it won't clean up all of
  2245.       the children.  Fortunately, I believe that all Unix flavors for
  2246.       which this is the case have available to the programmer the
  2247.       wait3() or waitpid() call, which allows the WNOHANG option to
  2248.       check whether or not there are any children waiting to be cleaned
  2249.       up.  Therefore, on any system that has wait3()/waitpid(), your
  2250.       signal handler should call wait3()/waitpid() over and over again
  2251.       with the WNOHANG option until there are no children left to clean
  2252.       up. Waitpid() is the preferred interface, as it is in POSIX.
  2253.  
  2254.       On SysV-derived systems, SIGCHLD signals are regenerated if there
  2255.       are child processes still waiting to be cleaned up after you exit
  2256.       the SIGCHLD signal handler.  Therefore, it's safe on most SysV
  2257.       systems to assume when the signal handler gets called that you
  2258.       only have to clean up one signal, and assume that the handler
  2259.       will get called again if there are more to clean up after it
  2260.       exits.
  2261.  
  2262.       On older systems, there is no way to prevent signal handlers
  2263.       from being automatically reset to SIG_DFL when the signal
  2264.       handler gets called.  On such systems, you have to put
  2265.       "signal(SIGCHILD, catcher_func)" (where "catcher_func" is the
  2266.       name of the handler function) as the last thing in the signal
  2267.       handler, so that it gets reset.
  2268.  
  2269.       Fortunately, newer implementations allow signal handlers to be
  2270.       installed without being reset to SIG_DFL when the handler
  2271.       function is called.  To get around this problem, on systems that
  2272.       do not have wait3()/waitpid() but do have SIGCLD, you need to
  2273.       reset the signal handler with a call to signal() after doing at
  2274.       least one wait() within the handler, each time it is called.  For
  2275.       backward compatibility reasons, System V will keep the old
  2276.       semantics (reset handler on call) of signal().  Signal handlers
  2277.       that stick can be installed with sigaction() or sigset().
  2278.  
  2279.       The summary of all this is that on systems that have waitpid()
  2280.       (POSIX) or wait3(), you should use that and your signal handler
  2281.       should loop, and on systems that don't, you should have one call
  2282.       to wait() per invocation of the signal handler.
  2283.  
  2284.       One more thing -- if you don't want to go through all of this
  2285.       trouble, there is a portable way to avoid this problem, although
  2286.       it is somewhat less efficient.  Your parent process should fork,
  2287.       and then wait right there and then for the child process to
  2288.       terminate.  The child process then forks again, giving you a
  2289.       child and a grandchild.  The child exits immediately (and hence
  2290.       the parent waiting for it notices its death and continues to
  2291.       work), and the grandchild does whatever the child was originally
  2292.       supposed to.  Since its parent died, it is inherited by init,
  2293.       which will do whatever waiting is needed.  This method is
  2294.       inefficient because it requires an extra fork, but is pretty much
  2295.       completely portable.
  2296.  
  2297. ------------------------------
  2298.  
  2299. Subject: How do I get lines from a pipe ... instead of only in larger blocks?
  2300. From: jik@rtfm.MIT.Edu (Jonathan I. Kamens)
  2301. Date: Sun, 16 Feb 92 20:59:28 -0500
  2302.  
  2303. 3.14) How do I get lines from a pipe as they are written instead of only in
  2304.       larger blocks?
  2305.  
  2306.       The stdio library does buffering differently depending on whether
  2307.       it thinks it's running on a tty.  If it thinks it's on a tty, it
  2308.       does buffering on a per-line basis; if not, it uses a larger
  2309.       buffer than one line.
  2310.  
  2311.       If you have the source code to the client whose buffering you
  2312.       want to disable, you can use setbuf() or setvbuf() to change the
  2313.       buffering.
  2314.  
  2315.       If not, the best you can do is try to convince the program that
  2316.       it's running on a tty by running it under a pty, e.g. by using
  2317.       the "pty" program mentioned in question 3.9.
  2318.  
  2319. ------------------------------
  2320.  
  2321. End of unix/faq Digest part 3 of 7
  2322. **********************************
  2323.  
  2324. --
  2325. Ted Timar - tmatimar@isgtec.com
  2326. ISG Technologies Inc., 6509 Airport Road, Mississauga, Ontario, Canada L4V 1S7
  2327.  
  2328.  
  2329. -------------------------------------------------------------------------------
  2330. Area # 2120  news.answers           05-30-94 04:34      Message # 13349
  2331. From    : Ted Timar
  2332. To      : ALL                                           
  2333. Subj    : Unix - Frequently Asked
  2334.  
  2335.  @FROM   :tmatimar@isgtec.com                                          
  2336.  @SUBJECT:Unix - Frequently Asked Questions (4/7) [Frequent posting]   
  2337.  @PACKOUT:05-31-9440,3193382879                                        
  2338. Message-ID: <unix-faq/faq/part4_770286840@rtfm.mit.edu>
  2339. Newsgroups: comp.unix.questions,comp.unix.shell,comp.answers,news.answers
  2340. Organization: ISG Technologies, Inc
  2341.  
  2342. Archive-name: unix-faq/faq/part4
  2343. Version: $Id: part4,v 2.5 1994/04/28 19:25:03 tmatimar Exp $
  2344.  
  2345. These seven articles contain the answers to some Frequently Asked
  2346. Questions often seen in comp.unix.questions and comp.unix.shell.
  2347. Please don't ask these questions again, they've been answered plenty
  2348. of times already - and please don't flame someone just because they may
  2349. not have read this particular posting.  Thank you.
  2350.  
  2351. This collection of documents is Copyright (c) 1994, Ted Timar.
  2352. All rights reserved.  Permission to distribute the collection is
  2353. hereby granted providing that distribution is electronic, no money
  2354. is involved, reasonable attempts are made to use the latest version
  2355. and all credits and this copyright notice are maintained.
  2356. Other requests for distribution will be considered.
  2357.  
  2358. All information here has been contributed with good intentions, but
  2359. none of it is guaranteed either by the contributors or myself to be
  2360. accurate.  The users of this information take all responsibility for
  2361. any damage that may occur.
  2362.  
  2363. Many FAQs, including this one, are available on the archive site
  2364. rtfm.mit.edu in the directory pub/usenet/news.answers.
  2365. The name under which a FAQ is archived appears in the "Archive-Name:"
  2366. line at the top of the article.  This FAQ is archived as
  2367. "unix-faq/faq/part[1-7]".
  2368.  
  2369. These articles are divided approximately as follows:
  2370.  
  2371.       1.*) General questions.
  2372.       2.*) Relatively basic questions, likely to be asked by beginners.
  2373.       3.*) Intermediate questions.
  2374.       4.*) Advanced questions, likely to be asked by people who thought
  2375.     they already knew all of the answers.
  2376.       5.*) Questions pertaining to the various shells, and the differences.
  2377.       6.*) An overview of Unix variants.
  2378.       7.*) An comparison of configuration management systems (RCS, SCCS).
  2379.  
  2380. This article includes answers to:
  2381.  
  2382.       4.1)  How do I read characters from a terminal without requiring the
  2383. user
  2384.               to hit RETURN?
  2385.       4.2)  How do I check to see if there are characters to be read without
  2386.               actually reading?
  2387.       4.3)  How do I find the name of an open file?
  2388.       4.4)  How can an executing program determine its own pathname?
  2389.       4.5)  How do I use popen() to open a process for reading AND writing?
  2390.       4.6)  How do I sleep() in a C program for less than one second?
  2391.       4.7)  How can I get setuid shell scripts to work?
  2392.       4.8)  How can I find out which user or process has a file open or is
  2393. using
  2394.             a particular file system (so that I can unmount it?)
  2395.       4.9)  How do I keep track of people who are fingering me?
  2396.       4.10) Is it possible to reconnect a process to a terminal after it has
  2397.             been disconnected, e.g. after starting a program in the background
  2398.             and logging out?
  2399.       4.11) Is it possible to "spy" on a terminal, displaying the output
  2400.             that's appearing on it on another terminal?
  2401.  
  2402. If you're looking for the answer to, say, question 4.5, and want to skip
  2403. everything else, you can search ahead for the regular expression "^4.5)".
  2404.  
  2405. While these are all legitimate questions, they seem to crop up in
  2406. comp.unix.questions or comp.unix.shell on an annual basis, usually
  2407. followed by plenty of replies (only some of which are correct) and then
  2408. a period of griping about how the same questions keep coming up.  You
  2409. may also like to read the monthly article "Answers to Frequently Asked
  2410. Questions" in the newsgroup "news.announce.newusers", which will tell
  2411. you what "UNIX" stands for.
  2412.  
  2413. With the variety of Unix systems in the world, it's hard to guarantee
  2414. that these answers will work everywhere.  Read your local manual pages
  2415. before trying anything suggested here.  If you have suggestions or
  2416. corrections for any of these answers, please send them to to
  2417. tmatimar@isgtec.com.
  2418.  
  2419. ----------------------------------------------------------------------
  2420.  
  2421. Subject: How do I read characters ... without requiring the user to hit
  2422. RETURN?
  2423. Date: Thu Mar 18 17:16:55 EST 1993
  2424.  
  2425. 4.1)  How do I read characters from a terminal without requiring the user
  2426.       to hit RETURN?
  2427.  
  2428.       Check out cbreak mode in BSD, ~ICANON mode in SysV.
  2429.  
  2430.       If you don't want to tackle setting the terminal parameters
  2431.       yourself (using the "ioctl(2)" system call) you can let the stty
  2432.       program do the work - but this is slow and inefficient, and you
  2433.       should change the code to do it right some time:
  2434.  
  2435.       #include <stdio.h>
  2436.       main()
  2437.       {
  2438.      int c;
  2439.  
  2440.      printf("Hit any character to continue\n");
  2441.      /*
  2442.       * ioctl() would be better here; only lazy
  2443.       * programmers do it this way:
  2444.       */
  2445.      system("/bin/stty cbreak");        /* or "stty raw" */
  2446.      c = getchar();
  2447.      system("/bin/stty -cbreak");
  2448.      printf("Thank you for typing %c.\n", c);
  2449.  
  2450.      exit(0);
  2451.       }
  2452.  
  2453.       Several people have sent me various more correct solutions to
  2454.       this problem.  I'm sorry that I'm not including any of them here,
  2455.       because they really are beyond the scope of this list.
  2456.  
  2457.       You might like to check out the documentation for the "curses"
  2458.       library of portable screen functions.  Often if you're interested
  2459.       in single-character I/O like this, you're also interested in
  2460.       doing some sort of screen display control, and the curses library
  2461.       provides various portable routines for both functions.
  2462.  
  2463. ------------------------------
  2464.  
  2465. Subject: How do I check to see if there are characters to be read ... ?
  2466. Date: Thu Mar 18 17:16:55 EST 1993
  2467.  
  2468. 4.2)  How do I check to see if there are characters to be read without
  2469.       actually reading?
  2470.  
  2471.       Certain versions of UNIX provide ways to check whether characters
  2472.       are currently available to be read from a file descriptor.  In
  2473.       BSD, you can use select(2).  You can also use the FIONREAD ioctl
  2474.       (see tty(4)), which returns the number of characters waiting to
  2475.       be read, but only works on terminals, pipes and sockets.  In
  2476.       System V Release 3, you can use poll(2), but that only works on
  2477.       streams.  In Xenix - and therefore Unix SysV r3.2 and later - the
  2478.       rdchk() system call reports whether a read() call on a given file
  2479.       descriptor will block.
  2480.  
  2481.       There is no way to check whether characters are available to be
  2482.       read from a FILE pointer.  (You could poke around inside stdio
  2483.       data structures to see if the input buffer is nonempty, but that
  2484.       wouldn't work since you'd have no way of knowing what will happen
  2485.       the next time you try to fill the buffer.)
  2486.  
  2487.       Sometimes people ask this question with the intention of writing
  2488.      if (characters available from fd)
  2489.       read(fd, buf, sizeof buf);
  2490.       in order to get the effect of a nonblocking read.  This is not
  2491.       the best way to do this, because it is possible that characters
  2492.       will be available when you test for availability, but will no
  2493.       longer be available when you call read.  Instead, set the
  2494.       O_NDELAY flag (which is also called FNDELAY under BSD) using the
  2495.       F_SETFL option of fcntl(2).  Older systems (Version 7, 4.1 BSD)
  2496.       don't have O_NDELAY; on these systems the closest you can get to
  2497.       a nonblocking read is to use alarm(2) to time out the read.
  2498.  
  2499. ------------------------------
  2500.  
  2501. Subject: How do I find the name of an open file?
  2502. Date: Thu Mar 18 17:16:55 EST 1993
  2503.  
  2504. 4.3)  How do I find the name of an open file?
  2505.  
  2506.       In general, this is too difficult.  The file descriptor may
  2507.       be attached to a pipe or pty, in which case it has no name.
  2508.       It may be attached to a file that has been removed.  It may
  2509.       have multiple names, due to either hard or symbolic links.
  2510.  
  2511.       If you really need to do this, and be sure you think long
  2512.       and hard about it and have decided that you have no choice,
  2513.       you can use find with the -inum and possibly -xdev option,
  2514.       or you can use ncheck, or you can recreate the functionality
  2515.       of one of these within your program.  Just realize that
  2516.       searching a 600 megabyte filesystem for a file that may not
  2517.       even exist is going to take some time.
  2518.  
  2519. ------------------------------
  2520.  
  2521. Subject: How can an executing program determine its own pathname?
  2522. Date: Thu Mar 18 17:16:55 EST 1993
  2523.  
  2524. 4.4)  How can an executing program determine its own pathname?
  2525.  
  2526.       Your program can look at argv[0]; if it begins with a "/", it is
  2527.       probably the absolute pathname to your program, otherwise your
  2528.       program can look at every directory named in the environment
  2529.       variable PATH and try to find the first one that contains an
  2530.       executable file whose name matches your program's argv[0] (which
  2531.       by convention is the name of the file being executed).  By
  2532.       concatenating that directory and the value of argv[0] you'd
  2533.       probably have the right name.
  2534.  
  2535.       You can't really be sure though, since it is quite legal for one
  2536.       program to exec() another with any value of argv[0] it desires.
  2537.       It is merely a convention that new programs are exec'd with the
  2538.       executable file name in argv[0].
  2539.  
  2540.       For instance, purely a hypothetical example:
  2541.  
  2542.  #include <stdio.h>
  2543.  main()
  2544.  {
  2545.      execl("/usr/games/rogue", "vi Thesis", (char *)NULL);
  2546.  }
  2547.  
  2548.       The executed program thinks its name (its argv[0] value) is
  2549.       "vi Thesis".   (Certain other programs might also think that
  2550.       the name of the program you're currently running is "vi Thesis",
  2551.       but of course this is just a hypothetical example, don't
  2552.       try it yourself :-)
  2553.  
  2554. ------------------------------
  2555.  
  2556. Subject: How do I use popen() to open a process for reading AND writing?
  2557. Date: Thu Mar 18 17:16:55 EST 1993
  2558.  
  2559. 4.5)  How do I use popen() to open a process for reading AND writing?
  2560.  
  2561.       The problem with trying to pipe both input and output to an
  2562.       arbitrary slave process is that deadlock can occur, if both
  2563.       processes are waiting for not-yet-generated input at the same
  2564.       time.  Deadlock can be avoided only by having BOTH sides follow a
  2565.       strict deadlock-free protocol, but since that requires
  2566.       cooperation from the processes it is inappropriate for a
  2567.       popen()-like library function.
  2568.  
  2569.       The 'expect' distribution includes a library of functions that a
  2570.       C programmer can call directly.  One of the functions does the
  2571.       equivalent of a popen for both reading and writing.  It uses ptys
  2572.       rather than pipes, and has no deadlock problem.  It's portable to
  2573.       both BSD and SV.  See the next answer for more about 'expect'.
  2574.  
  2575. ------------------------------
  2576.  
  2577. Subject: How do I sleep() in a C program for less than one second?
  2578. Date: Thu Mar 18 17:16:55 EST 1993
  2579.  
  2580. 4.6)  How do I sleep() in a C program for less than one second?
  2581.  
  2582.       The first thing you need to be aware of is that all you can
  2583.       specify is a MINIMUM amount of delay; the actual delay will
  2584.       depend on scheduling issues such as system load, and could be
  2585.       arbitrarily large if you're unlucky.
  2586.  
  2587.       There is no standard library function that you can count on in
  2588.       all environments for "napping" (the usual name for short
  2589.       sleeps).  Some environments supply a "usleep(n)" function which
  2590.       suspends execution for n microseconds.  If your environment
  2591.       doesn't support usleep(), here are a couple of implementations
  2592.       for BSD and System V environments.
  2593.  
  2594.       The following code is adapted from Doug Gwyn's System V emulation
  2595.       support for 4BSD and exploits the 4BSD select() system call.
  2596.       Doug originally called it 'nap()'; you probably want to call it
  2597.       "usleep()";
  2598.  
  2599.       /*
  2600.      usleep -- support routine for 4.2BSD system call emulations
  2601.      last edit: 29-Oct-1984 D A Gwyn
  2602.       */
  2603.  
  2604.       extern int select();
  2605.  
  2606.       int
  2607.       usleep( usec )    /* returns 0 if ok, else -1 */
  2608.      long  usec;  /* delay in microseconds */
  2609.      {
  2610.      static struct   /* `timeval' */
  2611.       {
  2612.       long tv_sec;  /* seconds */
  2613.       long tv_usec; /* microsecs */
  2614.       } delay;  /* _select() timeout */
  2615.  
  2616.      delay.tv_sec = usec / 1000000L;
  2617.      delay.tv_usec = usec % 1000000L;
  2618.  
  2619.      return select( 0, (long *)0, (long *)0, (long *)0, &delay );
  2620.      }
  2621.  
  2622.       On System V you might do it this way:
  2623.  
  2624.       /*
  2625.       subseconds sleeps for System V - or anything that has poll()
  2626.       Don Libes, 4/1/1991
  2627.  
  2628.       The BSD analog to this function is defined in terms of
  2629.       microseconds while poll() is defined in terms of milliseconds.
  2630.       For compatibility, this function provides accuracy "over the long
  2631.       run" by truncating actual requests to milliseconds and
  2632.       accumulating microseconds across calls with the idea that you are
  2633.       probably calling it in a tight loop, and that over the long run,
  2634.       the error will even out.
  2635.  
  2636.       If you aren't calling it in a tight loop, then you almost
  2637.       certainly aren't making microsecond-resolution requests anyway,
  2638.       in which case you don't care about microseconds.  And if you did,
  2639.       you wouldn't be using UNIX anyway because random system
  2640.       indigestion (i.e., scheduling) can make mincemeat out of any
  2641.       timing code.
  2642.  
  2643.       Returns 0 if successful timeout, -1 if unsuccessful.
  2644.  
  2645.       */
  2646.  
  2647.       #include <poll.h>
  2648.  
  2649.       int
  2650.       usleep(usec)
  2651.       unsigned int usec;  /* microseconds */
  2652.       {
  2653.      static subtotal = 0; /* microseconds */
  2654.      int msec;   /* milliseconds */
  2655.  
  2656.      /* 'foo' is only here because some versions of 5.3 have
  2657.       * a bug where the first argument to poll() is checked
  2658.       * for a valid memory address even if the second argument is 0.
  2659.       */
  2660.      struct pollfd foo;
  2661.  
  2662.      subtotal += usec;
  2663.      /* if less then 1 msec request, do nothing but remember it */
  2664.      if (subtotal < 1000) return(0);
  2665.      msec = subtotal/1000;
  2666.      subtotal = subtotal%1000;
  2667.      return poll(&foo,(unsigned long)0,msec);
  2668.       }
  2669.  
  2670.       Another possibility for nap()ing on System V, and probably other
  2671.       non-BSD Unices is Jon Zeeff's s5nap package, posted to
  2672.       comp.sources.misc, volume 4.  It does require a installing a
  2673.       device driver, but works flawlessly once installed.  (Its
  2674.       resolution is limited to the kernel HZ value, since it uses the
  2675.       kernel delay() routine.)
  2676.  
  2677. ------------------------------
  2678.  
  2679. Subject: How can I get setuid shell scripts to work?
  2680. Date: Thu Mar 18 17:16:55 EST 1993
  2681.  
  2682. 4.7)  How can I get setuid shell scripts to work?
  2683.  
  2684.       [ This is a long answer, but it's a complicated and frequently-asked
  2685.         question.  Thanks to Maarten Litmaath for this answer, and
  2686.         for the "indir" program mentioned below. ]
  2687.  
  2688.       Let us first assume you are on a UNIX variant (e.g. 4.3BSD or
  2689.       SunOS) that knows about so-called `executable shell scripts'.
  2690.       Such a script must start with a line like:
  2691.  
  2692.  #!/bin/sh
  2693.  
  2694.       The script is called `executable' because just like a real (binary)
  2695.       executable it starts with a so-called `magic number' indicating
  2696.       the type of the executable.  In our case this number is `#!' and
  2697.       the OS takes the rest of the first line as the interpreter for
  2698.       the script, possibly followed by 1 initial option like:
  2699.  
  2700.  #!/bin/sed -f
  2701.  
  2702.       Suppose this script is called `foo' and is found in /bin,
  2703.       then if you type:
  2704.  
  2705.  foo arg1 arg2 arg3
  2706.  
  2707.       the OS will rearrange things as though you had typed:
  2708.  
  2709.  /bin/sed -f /bin/foo arg1 arg2 arg3
  2710.  
  2711.       There is one difference though: if the setuid permission bit for
  2712.       `foo' is set, it will be honored in the first form of the
  2713.       command; if you really type the second form, the OS will honor
  2714.       the permission bits of /bin/sed, which is not setuid, of course.
  2715.  
  2716.       ----------
  2717.  
  2718.       OK, but what if my shell script does NOT start with such a `#!'
  2719.       line or my OS does not know about it?
  2720.  
  2721.       Well, if the shell (or anybody else) tries to execute it, the OS
  2722.       will return an error indication, as the file does not start with
  2723.       a valid magic number.  Upon receiving this indication the shell
  2724.       ASSUMES the file to be a shell script and gives it another try:
  2725.  
  2726.  /bin/sh shell_script arguments
  2727.  
  2728.       But we have already seen that a setuid bit on `shell_script' will
  2729.       NOT be honored in this case!
  2730.  
  2731.       ----------
  2732.  
  2733.       Right, but what about the security risks of setuid shell scripts?
  2734.  
  2735.       Well, suppose the script is called `/etc/setuid_script', starting
  2736.       with:
  2737.  
  2738.  #!/bin/sh
  2739.  
  2740.       Now let us see what happens if we issue the following commands:
  2741.  
  2742.  $ cd /tmp
  2743.  $ ln /etc/setuid_script -i
  2744.  $ PATH=.
  2745.  $ -i
  2746.  
  2747.       We know the last command will be rearranged to:
  2748.  
  2749.  /bin/sh -i
  2750.  
  2751.       But this command will give us an interactive shell, setuid to the
  2752.       owner of the script!
  2753.       Fortunately this security hole can easily be closed by making the
  2754.       first line:
  2755.  
  2756.  #!/bin/sh -
  2757.  
  2758.       The `-' signals the end of the option list: the next argument `-i'
  2759.       will be taken as the name of the file to read commands from, just
  2760.       like it should!
  2761.  
  2762.       ---------
  2763.  
  2764.       There are more serious problems though:
  2765.  
  2766.  $ cd /tmp
  2767.  $ ln /etc/setuid_script temp
  2768.  $ nice -20 temp &
  2769.  $ mv my_script temp
  2770.  
  2771.       The third command will be rearranged to:
  2772.  
  2773.  nice -20 /bin/sh - temp
  2774.  
  2775.       As this command runs so slowly, the fourth command might be able
  2776.       to replace the original `temp' with `my_script' BEFORE `temp' is
  2777.       opened by the shell!  There are 4 ways to fix this security hole:
  2778.  
  2779.  1)  let the OS start setuid scripts in a different, secure way
  2780.      - System V R4 and 4.4BSD use the /dev/fd driver to pass the
  2781.      interpreter a file descriptor for the script
  2782.  
  2783.  2)  let the script be interpreted indirectly, through a frontend
  2784.      that makes sure everything is all right before starting the
  2785.      real interpreter - if you use the `indir' program from
  2786.      comp.sources.unix the setuid script will look like this:
  2787.  
  2788.   #!/bin/indir -u
  2789.   #?/bin/sh /etc/setuid_script
  2790.  
  2791.  3)  make a `binary wrapper': a real executable that is setuid and
  2792.      whose only task is to execute the interpreter with the name of
  2793.      the script as an argument
  2794.  
  2795.  4)  make a general `setuid script server' that tries to locate the
  2796.      requested `service' in a database of valid scripts and upon
  2797.      success will start the right interpreter with the right
  2798.      arguments.
  2799.  
  2800.       ---------
  2801.  
  2802.       Now that we have made sure the right file gets interpreted, are
  2803.       there any risks left?
  2804.  
  2805.       Certainly!  For shell scripts you must not forget to set the PATH
  2806.       variable to a safe path explicitly.  Can you figure out why?
  2807.       Also there is the IFS variable that might cause trouble if not
  2808.       set properly.  Other environment variables might turn out to
  2809.       compromise security as well, e.g. SHELL...  Furthermore you must
  2810.       make sure the commands in the script do not allow interactive
  2811.       shell escapes!  Then there is the umask which may have been set
  2812.       to something strange...
  2813.  
  2814.       Etcetera.  You should realise that a setuid script `inherits' all
  2815.       the bugs and security risks of the commands that it calls!
  2816.  
  2817.       All in all we get the impression setuid shell scripts are quite a
  2818.       risky business!  You may be better off writing a C program instead!
  2819.  
  2820. ------------------------------
  2821.  
  2822. Subject: How can I find out which user or process has a file open ... ?
  2823. Date: Thu Mar 18 17:16:55 EST 1993
  2824.  
  2825. 4.8)  How can I find out which user or process has a file open or is using
  2826.       a particular file system (so that I can unmount it?)
  2827.  
  2828.       Use fuser (system V), fstat (BSD), ofiles (public domain) or
  2829.       pff (public domain).  These programs will tell you various things
  2830.       about processes using particular files.
  2831.  
  2832.       A port of the 4.3 BSD fstat to Dynix, SunOS and Ultrix
  2833.       can be found in archives of comp.sources.unix, volume 18.
  2834.  
  2835.       pff is part of the kstuff package, and works on quite a few systems.
  2836.       Instructions for obtaining kstuff are provided in question 3.10.
  2837.  
  2838. ------------------------------
  2839.  
  2840. Subject: How do I keep track of people who are fingering me?
  2841. From: jik@rtfm.MIT.EDU (Jonathan I. Kamens)
  2842. From: malenovi@plains.NoDak.edu (Nikola Malenovic)
  2843. Date: Mon, 23 Nov 1992 16:01:45 -0600
  2844.  
  2845. 4.9)  How do I keep track of people who are fingering me?
  2846.  
  2847.       Generally, you can't find out the userid of someone who is
  2848.       fingering you from a remote machine.  You may be able to
  2849.       find out which machine the remote request is coming from.
  2850.       One possibility, if your system supports it and assuming
  2851.       the finger daemon doesn't object, is to make your .plan file a
  2852.       "named pipe" instead of a plain file.  (Use 'mknod' to do this.)
  2853.  
  2854.       You can then start up a program that will open your .plan file
  2855.       for writing; the open will block until some other process (namely
  2856.       fingerd) opens the .plan for reading.  Now you can whatever you
  2857.       want through this pipe, which lets you show different .plan
  2858.       information every time someone fingers you.
  2859.  
  2860.       Of course, this may not work at all if your system doesn't
  2861.       support named pipes or if your local fingerd insists
  2862.       on having plain .plan files.
  2863.  
  2864.       Your program can also take the opportunity to look at the output
  2865.       of "netstat" and spot where an incoming finger connection is
  2866.       coming from, but this won't get you the remote user.
  2867.  
  2868.       Getting the remote userid would require that the remote site be
  2869.       running an identity service such as RFC 931.  There are now three
  2870.       RFC 931 implementations for popular BSD machines, and several
  2871.       applications (such as the wuarchive ftpd) supporting the server.
  2872.       For more information join the rfc931-users mailing list,
  2873.       rfc931-users-request@kramden.acf.nyu.edu.
  2874.  
  2875.       There are three caveats relating to this answer.  The first is
  2876.       that many NFS systems won't recognize the named pipe correctly.
  2877.       This means that trying to read the pipe on another machine will
  2878.       either block until it times out, or see it as a zero-length file,
  2879.       and never print it.
  2880.  
  2881.       The second problem is that on many systems, fingerd checks that
  2882.       the .plan file contains data (and is readable) before trying to
  2883.       read it.  This will cause remote fingers to miss your .plan file
  2884.       entirely.
  2885.  
  2886.       The third problem is that a system that supports named pipes
  2887.       usually has a fixed number of named pipes available on the
  2888.       system at any given time - check the kernel config file and
  2889.       FIFOCNT option.  If the number of pipes on the system exceeds the
  2890.       FIFOCNT value, the system blocks new pipes until somebody frees
  2891.       the resources.  The reason for this is that buffers are allocated
  2892.       in a non-paged memory.
  2893.  
  2894. ------------------------------
  2895.  
  2896. Subject: Is it possible to reconnect a process to a terminal ... ?
  2897. Date: Thu Mar 18 17:16:55 EST 1993
  2898.  
  2899. 4.10) Is it possible to reconnect a process to a terminal after it has
  2900.       been disconnected, e.g. after starting a program in the background
  2901.       and logging out?
  2902.  
  2903.       Most variants of Unix do not support "detaching" and "attaching"
  2904.       processes, as operating systems such as VMS and Multics support.
  2905.       However, there are two freely redistributable packages which can
  2906.       be used to start processes in such a way that they can be later
  2907.       reattached to a terminal.
  2908.  
  2909.       The first is "screen," which is described in the
  2910.       comp.sources.unix archives as "Screen, multiple windows on a CRT"
  2911.       (see the "screen-3.2" package in comp.sources.misc, volume 28.)
  2912.       This package will run on at least BSD, System V r3.2 and SCO UNIX.
  2913.  
  2914.       The second is "pty," which is described in the comp.sources.unix
  2915.       archives as a package to "Run a program under a pty session" (see
  2916.       "pty" in volume 23).  pty is designed for use under BSD-like
  2917.       system only.
  2918.  
  2919.       Neither of these packages is retroactive, i.e. you must have
  2920.       started a process under screen or pty in order to be able to
  2921.       detach and reattach it.
  2922.  
  2923. ------------------------------
  2924.  
  2925. Subject: Is it possible to "spy" on a terminal ... ?
  2926. Date: Thu Mar 18 17:16:55 EST 1993
  2927.  
  2928. 4.11) Is it possible to "spy" on a terminal, displaying the output
  2929.       that's appearing on it on another terminal?
  2930.  
  2931.       There are a few different ways you can do this, although none
  2932.       of them is perfect:
  2933.  
  2934.       * kibitz allows two (or more) people to interact with a shell
  2935.         (or any arbitary program).  Uses include:
  2936.  
  2937.  - watching or aiding another person's terminal session;
  2938.  - recording a conversation while retaining the ability to
  2939.    scroll backwards, save the conversation, or even edit it
  2940.    while in progress;
  2941.  - teaming up on games, document editing, or other cooperative
  2942.    tasks where each person has strengths and weakness that
  2943.    complement one another.
  2944.  
  2945.         kibitz comes as part of the expect distribution.  See question 3.9.
  2946.  
  2947.         kibitz requires permission from the person to be spyed upon.  To
  2948.         spy without permission requires less pleasant approaches:
  2949.  
  2950.       * You can write a program that rummages through Kernel structures
  2951.         and watches the output buffer for the terminal in question,
  2952.         displaying characters as they are output.  This, obviously, is
  2953.         not something that should be attempted by anyone who does not
  2954.         have experience working with the Unix kernel.  Furthermore,
  2955.         whatever method you come up with will probably be quite
  2956.         non-portable.
  2957.  
  2958.       * If you want to do this to a particular hard-wired terminal all
  2959.         the time (e.g. if you want operators to be able to check the
  2960.         console terminal of a machine from other machines), you can
  2961.         actually splice a monitor into the cable for the terminal.  For
  2962.         example, plug the monitor output into another machine's serial
  2963.         port, and run a program on that port that stores its input
  2964.         somewhere and then transmits it out *another* port, this one
  2965.         really going to the physical terminal.  If you do this, you have
  2966.         to make sure that any output from the terminal is transmitted
  2967.         back over the wire, although if you splice only into the
  2968.         computer->terminal wires, this isn't much of a problem.  This is
  2969.         not something that should be attempted by anyone who is not very
  2970.         familiar with terminal wiring and such.
  2971.  
  2972. ------------------------------
  2973.  
  2974. End of unix/faq Digest part 4 of 7
  2975. **********************************
  2976.  
  2977. --
  2978. Ted Timar - tmatimar@isgtec.com
  2979. ISG Technologies Inc., 6509 Airport Road, Mississauga, Ontario, Canada L4V 1S7
  2980.  
  2981.  
  2982. -------------------------------------------------------------------------------
  2983. Area # 2120  news.answers           05-30-94 04:34      Message # 13351
  2984. From    : Ted Timar
  2985. To      : ALL                                           
  2986. Subj    : Unix - Frequently Asked
  2987.  
  2988.  @FROM   :tmatimar@isgtec.com                                          
  2989.  @SUBJECT:Unix - Frequently Asked Questions (5/7) [Frequent posting]   
  2990.  @PACKOUT:05-31-9440,3193382879                                        
  2991. Message-ID: <unix-faq/faq/part5_770286840@rtfm.mit.edu>
  2992. Newsgroups: comp.unix.questions,comp.unix.shell,comp.answers,news.answers
  2993. Organization: ISG Technologies, Inc
  2994.  
  2995. Archive-name: unix-faq/faq/part5
  2996. Version: $Id: part5,v 2.5 1994/04/28 19:25:03 tmatimar Exp $
  2997.  
  2998. These seven articles contain the answers to some Frequently Asked
  2999. Questions often seen in comp.unix.questions and comp.unix.shell.
  3000. Please don't ask these questions again, they've been answered plenty
  3001. of times already - and please don't flame someone just because they may
  3002. not have read this particular posting.  Thank you.
  3003.  
  3004. This collection of documents is Copyright (c) 1994, Ted Timar.
  3005. All rights reserved.  Permission to distribute the collection is
  3006. hereby granted providing that distribution is electronic, no money
  3007. is involved, reasonable attempts are made to use the latest version
  3008. and all credits and this copyright notice are maintained.
  3009. Other requests for distribution will be considered.
  3010.  
  3011. All information here has been contributed with good intentions, but
  3012. none of it is guaranteed either by the contributors or myself to be
  3013. accurate.  The users of this information take all responsibility for
  3014. any damage that may occur.
  3015.  
  3016. Many FAQs, including this one, are available on the archive site
  3017. rtfm.mit.edu in the directory pub/usenet/news.answers.
  3018. The name under which a FAQ is archived appears in the "Archive-Name:"
  3019. line at the top of the article.  This FAQ is archived as
  3020. "unix-faq/faq/part[1-7]".
  3021.  
  3022. These articles are divided approximately as follows:
  3023.  
  3024.       1.*) General questions.
  3025.       2.*) Relatively basic questions, likely to be asked by beginners.
  3026.       3.*) Intermediate questions.
  3027.       4.*) Advanced questions, likely to be asked by people who thought
  3028.     they already knew all of the answers.
  3029.       5.*) Questions pertaining to the various shells, and the differences.
  3030.       6.*) An overview of Unix variants.
  3031.       7.*) An comparison of configuration management systems (RCS, SCCS).
  3032.  
  3033. This article includes answers to:
  3034.  
  3035.       5.1)  Can shells be classified into categories?
  3036.       5.2)  How do I "include" one shell script from within another
  3037.             shell script?
  3038.       5.3)  Do all shells have aliases?  Is there something else that
  3039.             can be used?
  3040.       5.4)  How are shell variables assigned?
  3041.       5.5)  How can I tell if I am running an interactive shell?
  3042.       5.6)  What "dot" files do the various shells use?
  3043.       5.7)  I would like to know more about the differences between the
  3044.             various shells.  Is this information available some place?
  3045.  
  3046. If you're looking for the answer to, say, question 5.5, and want to skip
  3047. everything else, you can search ahead for the regular expression "^5.5)".
  3048.  
  3049. While these are all legitimate questions, they seem to crop up in
  3050. comp.unix.questions or comp.unix.shell on an annual basis, usually
  3051. followed by plenty of replies (only some of which are correct) and then
  3052. a period of griping about how the same questions keep coming up.  You
  3053. may also like to read the monthly article "Answers to Frequently Asked
  3054. Questions" in the newsgroup "news.announce.newusers", which will tell
  3055. you what "UNIX" stands for.
  3056.  
  3057. With the variety of Unix systems in the world, it's hard to guarantee
  3058. that these answers will work everywhere.  Read your local manual pages
  3059. before trying anything suggested here.  If you have suggestions or
  3060. corrections for any of these answers, please send them to to
  3061. tmatimar@isgtec.com.
  3062.  
  3063. ----------------------------------------------------------------------
  3064.  
  3065. Subject: Can shells be classified into categories?
  3066. From: wicks@dcdmjw.fnal.gov (Matthew Wicks)
  3067. Date: Wed, 7 Oct 92 14:28:18 -0500
  3068.  
  3069.  
  3070. 5.1)  Can shells be classified into categories?
  3071.  
  3072.       In general there are two main class of shells.  The first class
  3073.       are those shells derived from the Bourne shell which includes sh,
  3074.       ksh, bash, and zsh.  The second class are those shells derived
  3075.       from C shell and include csh and tcsh.  In addition there is rc
  3076.       which most people consider to be in a "class by itself" although
  3077.       some people might argue that rc belongs in the Bourne shell class.
  3078.  
  3079.       With the classification above, using care, it is possible to
  3080.       write scripts that will work for all the shells from the Bourne
  3081.       shell category, and write other scripts that will work for all of
  3082.       the shells from the C shell category.
  3083.  
  3084. ------------------------------
  3085.  
  3086. Subject: How do I "include" one shell script from within another shell script?
  3087. From: wicks@dcdmjw.fnal.gov (Matthew Wicks)
  3088. Date: Wed, 7 Oct 92 14:28:18 -0500
  3089.  
  3090. 5.2)  How do I "include" one shell script from within another shell script?
  3091.  
  3092.       All of the shells from the Bourne shell category (including rc)
  3093.       use the "." command.  All of the shells from the C shell category
  3094.       use "source".
  3095.  
  3096. ------------------------------
  3097.  
  3098. Subject: Do all shells have aliases?  Is there something else that can be
  3099. used?
  3100. From: wicks@dcdmjw.fnal.gov (Matthew Wicks)
  3101. Date: Wed, 7 Oct 92 14:28:18 -0500
  3102.  
  3103. 5.3)  Do all shells have aliases?  Is there something else that can be used?
  3104.  
  3105.       All of the major shells other than sh have aliases, but they
  3106.       don't all work the same way.  For example, some don't accept
  3107.       arguments.
  3108.  
  3109.       Although not strictly equivalent, shell functions (which exist in
  3110.       most shells from the Bourne shell category) have almost the same
  3111.       functionality of aliases.  Shell functions can do things that
  3112.       aliases can't do.  Shell functions did not exist in bourne shells
  3113.       derived from Version 7 Unix, which includes System III and BSD 4.2.
  3114.       BSD 4.3 and System V shells do support shell functions.
  3115.  
  3116.       Use unalias to remove aliases and unset to remove functions.
  3117.  
  3118. ------------------------------
  3119.  
  3120. Subject: How are shell variables assigned?
  3121. From: wicks@dcdmjw.fnal.gov (Matthew Wicks)
  3122. Date: Wed, 7 Oct 92 14:28:18 -0500
  3123.  
  3124. 5.4)  How are shell variables assigned?
  3125.  
  3126.       The shells from the C shell category use "set variable=value" for
  3127.       variables local to the shell and "setenv variable value" for
  3128.       environment variables.  To get rid of variables in these shells
  3129.       use unset and unsetenv.  The shells from the Bourne shell
  3130.       category use "variable=value" and may require an "export
  3131.       VARIABLE_NAME" to place the variable into the environment.  To
  3132.       get rid of the variables use unset.
  3133.  
  3134. ------------------------------
  3135.  
  3136. Subject: How can I tell if I am running an interactive shell?
  3137. From: wicks@dcdmjw.fnal.gov (Matthew Wicks)
  3138. From: dws@ssec.wisc.edu (DaviD W. Sanderson)
  3139. Date: Fri, 23 Oct 92 11:59:19 -0600
  3140.  
  3141. 5.5)  How can I tell if I am running an interactive shell?
  3142.  
  3143.       In the C shell category, look for the variable $prompt.
  3144.  
  3145.       In the Bourne shell category, you can look for the variable $PS1,
  3146.       however, it is better to check the variable $-.  If $- contains
  3147.       an 'i', the shell is interactive.  Test like so:
  3148.  
  3149.    case $- in
  3150.    *i*)    # do things for interactive shell
  3151.            ;;
  3152.    *)      # do things for non-interactive shell
  3153.            ;;
  3154.    esac
  3155.  
  3156. ------------------------------
  3157.  
  3158. Subject: What "dot" files do the various shells use?
  3159. From: wicks@dcdmjw.fnal.gov (Matthew Wicks)
  3160. From: tmb@idiap.ch (Thomas M. Breuel)
  3161. Date: Wed, 28 Oct 92 03:30:36 +0100
  3162.  
  3163. 5.6)  What "dot" files do the various shells use?
  3164.  
  3165.       Although this may not be a complete listing, this provides the
  3166.       majority of information.
  3167.  
  3168.       csh
  3169.    Some versions have system-wide .cshrc and .login files.  Every
  3170.    version puts them in different places.
  3171.  
  3172.    Start-up (in this order):
  3173.        .cshrc   - always.
  3174.        .login   - login shells.
  3175.  
  3176.    Upon termination:
  3177.               .logout  - login shells.
  3178.  
  3179.    Others:
  3180.        .history - saves the history (based on $savehist).
  3181.  
  3182.       tcsh
  3183.    Start-up (in this order):
  3184.        /etc/csh.cshrc - always.
  3185.        /etc/csh.login - login shells.
  3186.        .tcshrc        - always.
  3187.        .cshrc         - if no .tcshrc was present.
  3188.        .login         - login shells
  3189.  
  3190.    Upon termination:
  3191.               .logout        - login shells.
  3192.  
  3193.    Others:
  3194.        .history       - saves the history (based on $savehist).
  3195.        .cshdirs       - saves the directory stack.
  3196.  
  3197.       sh
  3198.    Start-up (in this order):
  3199.        /etc/profile - login shells.
  3200.        .profile     - login shells.
  3201.  
  3202.    Upon termination:
  3203.        any command (or script) specified using the command:
  3204.    trap "command" 0
  3205.  
  3206.       ksh
  3207.    Start-up (in this order):
  3208.        /etc/profile - login shells.
  3209.        .profile     - login shells.
  3210.        $ENV         - always, if it is set.
  3211.  
  3212.    Upon termination:
  3213.        any command (or script) specified using the command:
  3214.    trap "command" 0
  3215.  
  3216.       bash
  3217.    Start-up (in this order):
  3218.               /etc/profile  - login shells.
  3219.               .bash_profile - login shells.
  3220.               .profile      - login if no .bash_profile is present.
  3221.               .bashrc       - interactive non-login shells.
  3222.               $ENV          - always, if it is set.
  3223.  
  3224.    Upon termination:
  3225.               .bash_logout  - login shells.
  3226.  
  3227.    Others:
  3228.               .inputrc      - Readline initialization.
  3229.  
  3230.       zsh
  3231.    Start-up (in this order):
  3232.               .zshenv   - always, unless -f is specified.
  3233.               .zprofile - login shells.
  3234.               .zshrc    - interactive shells, unless -f is specified.
  3235.               .zlogin   - login shells.
  3236.  
  3237.    Upon termination:
  3238.               .zlogout  - login shells.
  3239.  
  3240.       rc
  3241.    Start-up:
  3242.               .rcrc - login shells
  3243.  
  3244. ------------------------------
  3245.  
  3246. Subject: I would like to know more about the differences ... ?
  3247. From: wicks@dcdmjw.fnal.gov (Matthew Wicks)
  3248. Date: Wed, 7 Oct 92 14:28:18 -0500
  3249.  
  3250. 5.7)  I would like to know more about the differences between the
  3251.       various shells.  Is this information available some place?
  3252.  
  3253.       A very detailed comparison of sh, csh, tcsh, ksh, bash, zsh, and
  3254.       rc is available via anon.  ftp in several places:
  3255.  
  3256.       cs.uwp.edu (131.210.1.4):pub/vi/docs/shell-100.BetaA.Z
  3257.       utsun.s.u-tokyo.ac.jp:misc/vi-archive/docs/shell-100.BetaA.Z
  3258.  
  3259.       This file compares the flags, the programming syntax,
  3260.       input/output redirection, and parameters/shell environment
  3261.       variables.  It doesn't discuss what dot files are used and the
  3262.       inheritance for environment variables and functions.
  3263.  
  3264. ------------------------------
  3265.  
  3266. End of unix/faq Digest part 5 of 7
  3267. **********************************
  3268.  
  3269. --
  3270. Ted Timar - tmatimar@isgtec.com
  3271. ISG Technologies Inc., 6509 Airport Road, Mississauga, Ontario, Canada L4V 1S7
  3272.  
  3273.  
  3274. -------------------------------------------------------------------------------
  3275. Area # 2120  news.answers           05-30-94 04:34      Message # 13352
  3276. From    : Ted Timar
  3277. To      : ALL                                           
  3278. Subj    : Unix - Frequently Asked
  3279.  
  3280.  @FROM   :tmatimar@isgtec.com                                          
  3281.  @SUBJECT:Unix - Frequently Asked Questions (6/7) [Frequent posting]   
  3282.  @PACKOUT:05-31-9440,3193382879                                        
  3283. Message-ID: <unix-faq/faq/part6_770286840@rtfm.mit.edu>
  3284. Newsgroups: comp.unix.questions,comp.unix.shell,comp.answers,news.answers
  3285. Organization: ISG Technologies, Inc
  3286.  
  3287. Archive-name: unix-faq/faq/part6
  3288. Version: $Id: part6,v 2.5 1994/04/28 19:25:03 tmatimar Exp $
  3289.  
  3290. These seven articles contain the answers to some Frequently Asked
  3291. Questions often seen in comp.unix.questions and comp.unix.shell.
  3292. Please don't ask these questions again, they've been answered plenty
  3293. of times already - and please don't flame someone just because they may
  3294. not have read this particular posting.  Thank you.
  3295.  
  3296. This collection of documents is Copyright (c) 1994, Ted Timar.
  3297. All rights reserved.  Permission to distribute the collection is
  3298. hereby granted providing that distribution is electronic, no money
  3299. is involved, reasonable attempts are made to use the latest version
  3300. and all credits and this copyright notice are maintained.
  3301. Other requests for distribution will be considered.
  3302.  
  3303. All information here has been contributed with good intentions, but
  3304. none of it is guaranteed either by the contributors or myself to be
  3305. accurate.  The users of this information take all responsibility for
  3306. any damage that may occur.
  3307.  
  3308. Many FAQs, including this one, are available on the archive site
  3309. rtfm.mit.edu in the directory pub/usenet/news.answers.
  3310. The name under which a FAQ is archived appears in the "Archive-Name:"
  3311. line at the top of the article.  This FAQ is archived as
  3312. "unix-faq/faq/part[1-7]".
  3313.  
  3314. These articles are divided approximately as follows:
  3315.  
  3316.       1.*) General questions.
  3317.       2.*) Relatively basic questions, likely to be asked by beginners.
  3318.       3.*) Intermediate questions.
  3319.       4.*) Advanced questions, likely to be asked by people who thought
  3320.            they already knew all of the answers.
  3321.       5.*) Questions pertaining to the various shells, and the differences.
  3322.       6.*) An overview of Unix variants.
  3323.       7.*) An comparison of configuration management systems (RCS, SCCS).
  3324.  
  3325. This article includes answers to:
  3326.  
  3327.       6.1)  Disclaimer, introduction and acknowledgements.
  3328.       6.2)  A very brief look at Unix history.
  3329.       6.3)  Main Unix flavors.
  3330.       6.4)  Unix Standards.
  3331.       6.5)  Identifying your Unix flavor.
  3332.       6.6)  Brief notes on some well-known (commercial/PD) Unices.
  3333.       6.7)  Real-time Unices.
  3334.       6.8)  Unix glossary.
  3335.  
  3336. If you're looking for the answer to, say, question 6.5, and want to skip
  3337. everything else, you can search ahead for the regular expression "^6.5)".
  3338.  
  3339. While these are all legitimate questions, they seem to crop up in
  3340. comp.unix.questions or comp.unix.shell on an annual basis, usually
  3341. followed by plenty of replies (only some of which are correct) and then
  3342. a period of griping about how the same questions keep coming up.  You
  3343. may also like to read the monthly article "Answers to Frequently Asked
  3344. Questions" in the newsgroup "news.announce.newusers", which will tell
  3345. you what "UNIX" stands for.
  3346.  
  3347. With the variety of Unix systems in the world, it's hard to guarantee
  3348. that these answers will work everywhere.  Read your local manual pages
  3349. before trying anything suggested here.  If you have suggestions or
  3350. corrections for any of these answers, please send them to to
  3351. tmatimar@isgtec.com.
  3352.  
  3353. ----------------------------------------------------------------------
  3354.  
  3355. Subject: Disclaimer, introduction and acknowledgements.
  3356. From: "Pierre (P.) Lewis" <lew@bnr.ca>
  3357. Date: Wed Nov 17 11:21:35 EST 1993
  3358. X-Version: 2.5
  3359.  
  3360. 6.1)  Disclaimer, introduction and acknowledgements.
  3361.  
  3362.       The following is offered with no guarantee as to accuracy or
  3363.       completeness.  I have done what I can in the time available,
  3364.       often with conflicting information, and it still is very much work
  3365.       in progress.  I hope to keep improving this summary.  Comments and
  3366.       corrections welcome:  lew@bnr.ca.
  3367.  
  3368.       First a short definition.  By Unix we mean an operating system
  3369.       typically written in C, with a hierarchical file system,
  3370.       integration of file and device I/O, whose system call interface
  3371.       includes services such as fork(), pipe(), and whose user
  3372.       interface includes tools such as cc, troff, grep, awk, and a
  3373.       choice of shell.  Note that UNIX is a registered trademark of USL
  3374.       (AT&T), but will be used here in its generic sense.
  3375.  
  3376.       Most Unices (the more common plural form) are derived more or
  3377.       less directly from AT&T code (some code from the first C version
  3378.       is presumably still left in most), but there are also clones
  3379.       (i.e. Unix-compatible systems with no AT&T code).
  3380.  
  3381.       In addition, there are also Unix-like environments (e.g. VOS)
  3382.       sitting on top of other OSs, and OSs inspired from Unix (yes,
  3383.       even DOS!).  These are not covered here.  Little on real-time
  3384.       Unices yet (although more is planned).
  3385.  
  3386.       Unix comes in an incredible variety of flavors.  This is to a
  3387.       large extent due to availability of sources and the ease of
  3388.       porting and modifying Unix.  Typically, a vendor of Unix will
  3389.       start with one basic flavor (see below), take ideas/code from the
  3390.       other major flavor, add and change many things, etc.  This
  3391.       results in yet another new Unix flavor.  Today, there are
  3392.       literally hundreds of Unices available, the closest thing to
  3393.       standard Unix being (by definition) System V.
  3394.  
  3395.       This answer was put together mostly from information on the net
  3396.       and email.  Some specific sources are also mentioned in the
  3397.       appropriate sections.
  3398.  
  3399.       Acknowledgements: (in addition to references): pat@bnr.ca,
  3400.       guy@auspex.com, pen@lysator.liu.se, mikes@ingres.com,
  3401.       mjd@saul.cis.upenn.edu, root%candle.uucp@ls.com, ee@atbull.bull.co.at,
  3402.       Aaron_Dailey@stortek.com, ralph@dci.pinetree.org, sbdah@mcshh.hanse.de,
  3403.       macmach@andrew.cmu.edu, jwa@alw.nih.gov [4.4BSD], roeber@axpvms.cern.ch,
  3404.       bob@pta.pyramid.com.au, bad@flatlin.ka.sub.org, m5@vail.tivoli.com,
  3405.       dan@fch.wimsey.bc.ca, jlbrand@uswnvg.com, jpazer@usl.com,
  3406.       ym@satelnet.org, merritt@gendev.slc.paramax.com, many that I forgot,
  3407.       and all the other folks whose posts I read. Many thanks!
  3408.  
  3409. ------------------------------
  3410.  
  3411. Subject: A very brief look at Unix history.
  3412. From: "Pierre (P.) Lewis" <lew@bnr.ca>
  3413. Date: Wed Nov 17 11:21:35 EST 1993
  3414. X-Version: 2.5
  3415.  
  3416. 6.2)  A very brief look at Unix history.
  3417.  
  3418.       Unix history goes back to 1969 and the famous "little-used PDP-7
  3419.       in a corner" on which Ken Thompson, Dennis Ritchie (the R in K&R)
  3420.       and others started work on what was to become Unix.  The name
  3421.       "Unix" was intended as a pun on Multics (and was written "Unics"
  3422.       at first -- UNiplexed Information and Computing System).
  3423.  
  3424.       For the first 10 years, Unix development was essentially confined
  3425.       to Bell Labs.  These initial versions were labeled "Version n" or
  3426.       "Nth Edition" (of the manuals), and were for DEC's PDP-11 (16
  3427.       bits) and later VAXen (32 bits).  Some significant versions
  3428.       include:
  3429.  
  3430.       V1 (1971):  1st Unix version, in assembler on a PDP-11/20.
  3431.          Included file system, fork(), roff, ed.  Was used as a text
  3432.          processing tool for preparation of patents.  Pipe() appeared
  3433.          first in V2!
  3434.  
  3435.       V4 (1973):  Rewritten in C, which is probably the most
  3436.          significant event in this OS's history: it means Unix can be
  3437.          ported to a new hardware in months, and changes are easy.  The
  3438.          C language was originally designed for the Unix operating
  3439.          system, and hence there is a strong synergy between C and Unix.
  3440.  
  3441.       V6 (1975):  First version of Unix widely available outside
  3442.          Bell Labs (esp.  in universities).  This was also the start of
  3443.          Unix diversity and popularity.  1.xBSD (PDP-11) was derived
  3444.          from this version.  J. Lions published "A commentary on the
  3445.          Unix Operating System" based on V6.
  3446.  
  3447.       V7 (1979):  For many, this is the "last true Unix", an
  3448.          "improvement over all preceding and following Unices"
  3449.          [Bourne].  It included full K&R C, uucp, Bourne shell.  V7 was
  3450.          ported to the VAX as 32V.  The V7 kernel was a mere 40
  3451.          Kbytes!
  3452.  
  3453.          Here (for reference) are the system calls of V7:
  3454.             _exit, access, acct, alarm, brk, chdir, chmod, chown,
  3455.             chroot, close, creat, dup, dup2, exec*, exit, fork, fstat,
  3456.             ftime, getegid, geteuid, getgid, getpid, getuid, gtty,
  3457.             indir, ioctl, kill, link, lock, lseek, mknod, mount,
  3458.             mpxcall, nice, open, pause, phys, pipe, pkoff, pkon,
  3459.             profil, ptrace, read, sbrk, setgid, setuid, signal, stat,
  3460.             stime, stty, sync, tell, time, times, umask, umount,
  3461.             unlink, utime, wait, write.
  3462.  
  3463.       These Vn versions were developed by the Computer Research Group
  3464.       (CRG) of Bell Labs.  Another group, the Unix System Group (USG),
  3465.       was responsible for support.  A third group at Bell Labs was also
  3466.       involved in Unix development, the Programmer's WorkBench (PWB),
  3467.       to which we owe, for example, sccs, named pipes and other
  3468.       important ideas.  Both groups were merged into Unix System
  3469.       Development Lab in 1983.
  3470.  
  3471.       Another variant of Unix was CB Unix (Columbus Unix) from the Columbus
  3472.       branch of Bell Labs, responsible of Operations Support Systems. Its
  3473.       main contribution was parts of SV IPC.
  3474.  
  3475.       Work on Unix continued at Bell Labs in the 1980s.  The V series
  3476.       was further developed by the CRG (Stroustrup mentions V10 in the
  3477.       2nd edition of his book on C++), but we don't seem to hear much
  3478.       about this otherwise.  The company now responsible for Unix
  3479.       (System V) is called Unix System Laboratories (USL) and is
  3480.       majority-owned by AT&T.  Novell has bought USL (early 93)?!
  3481.       Novell has given rights to the "UNIX" trademark to X/Open (late 93).
  3482.  
  3483.       But much happened to Unix outside AT&T, especially at Berkeley
  3484.       (where the other major flavor comes from).  Vendors (esp. of
  3485.       workstations) also contributed much (e.g. Sun's NFS).
  3486.  
  3487.       The book "Life with Unix" by Don Libes and Sandy Ressler is
  3488.       fascinating reading for anyone interested in Unix, and covers a
  3489.       lot of the history, interactions, etc..  Much in the present
  3490.       section is summarized from this book.
  3491.  
  3492. ------------------------------
  3493.  
  3494. Subject: Main Unix flavors.
  3495. From: "Pierre (P.) Lewis" <lew@bnr.ca>
  3496. Date: Wed Nov 17 11:21:35 EST 1993
  3497. X-Version: 2.5
  3498.  
  3499. 6.3)  Main Unix flavors.
  3500.  
  3501.       Until recently, there were basically two main flavors of Unix:
  3502.       System V (five) from AT&T, and the Berkeley Software Distribution
  3503.       (BSD).  SVR4 is essentially a merge of these two flavors.  End
  3504.       '91, OSF/1 from the Open Software Foundation was released (as a
  3505.       direct competitor to System V) and may (future will tell) change
  3506.       this picture.
  3507.  
  3508.       The following lists the main releases and features of System V,
  3509.       BSD and OSF/1.
  3510.  
  3511.       System V from AT&T.  Typical of Intel hardware.  Most often
  3512.          ported Unix, typically with BSD enhancements (csh, job
  3513.          control, termcap, curses, vi, symbolic links).  System V
  3514.          evolution is now overseen by Unix International (UI).  UI
  3515.          members include AT&T, Sun, ....
  3516.          Newsgroup: comp.unix.sysv[23]86.  Main releases:
  3517.  
  3518.          - System III (1982): first commercial Unix from AT&T
  3519.            - FIFOs (named pipes)  (later?)
  3520.  
  3521.          - System V (1983):
  3522.            - IPC package (shm, msg, sem)
  3523.  
  3524.          - SVR2 (1984):
  3525.            - shell functions (sh)
  3526.            - SVID (System V Interface Definition)
  3527.  
  3528.          - SVR3 (1986) for ? platforms:
  3529.            - STREAMS (inspired by V8), poll(), TLI (network software)
  3530.            - RFS
  3531.            - shared libs
  3532.            - SVID 2
  3533.            - demand paging (if hardware supports)
  3534.  
  3535.          - SVR3.2:
  3536.            - merge with Xenix (Intel 80386)
  3537.            - networking
  3538.  
  3539.          - SVR4 (1988), mainstream of Unix implementations, merge of
  3540.            System V, BSD, and SunOS.
  3541.            - From SVR3: sysadmin, terminal I/F, printer (from BSD?),
  3542.              RFS, STREAMS, uucp
  3543.            - From BSD: FFS, TCP/IP, sockets, select(), csh
  3544.            - From SunOS: NFS, OpenLook GUI, X11/NeWS, virtual memory
  3545.              subsystem with memory-mapped files, shared libraries
  3546.              (!= SVR3 ones?)
  3547.            - ksh
  3548.            - ANSI C
  3549.            - Internationalization (8-bit clean)
  3550.            - ABI (Application Binary Interface -- routines instead of traps)
  3551.            - POSIX, X/Open, SVID3
  3552.  
  3553.          - SVR4.1
  3554.            - async I/O (from SunOS?)
  3555.  
  3556.          - SVR4.2 (based on SVR4.1ES)
  3557.            - Veritas FS, ACLs
  3558.            - Dynamically loadable kernel modules
  3559.  
  3560.          - Future:
  3561.            - SVR4 MP (multiprocessor)
  3562.            - Use of Chorus microkernel?
  3563.  
  3564.       Berkeley Software Distribution (BSD).  Typical of VAXen, RISCs,
  3565.          many workstations.  More dynamic, research versions now than
  3566.          System V.  BSD is responsible for much of the popularity of
  3567.          Unix.  Most enhancements to Unix started here.  The group
  3568.          responsible at UCB (University of California at Berkeley) is
  3569.          the Computer System Research Group (CSRG).  They closed down
  3570.          in 1992.  Newsgroup: comp.unix.bsd.  Main releases:
  3571.  
  3572.          (much reorganized wrt dates and releases, hope it's converging)
  3573.  
  3574.          - 2.xBSD (1978) for PDP-11, still of significance? (2.11BSD
  3575.            was released in 1992!).
  3576.            - csh
  3577.  
  3578.          - 3BSD (1978):
  3579.            - virtual memory
  3580.  
  3581.          - 4.?BSD:
  3582.            - termcap, curses
  3583.            - vi
  3584.  
  3585.          - 4.0BSD (1980):
  3586.  
  3587.          - 4.1BSD (?): base of later AT&T CRG versions
  3588.            - job control
  3589.            - automatic kernel config
  3590.            - vfork()
  3591.  
  3592.          - 4.2BSD (1983):
  3593.            - TCP/IP, sockets, ethernet
  3594.            - UFS: long file names, symbolic links
  3595.            - new reliable signals (4.1 reliable signals now in SVR3)
  3596.            - select()
  3597.  
  3598.          - 4.3BSD (1986) for VAX, ?:
  3599.          - 4.3 Tahoe (1988): 4.3BSD with sources, support for Tahoe
  3600.            (32-bit supermini)
  3601.            - Fat FFS
  3602.            - New TCP algorithms
  3603.          - 4.3 Reno (1990) for VAX, Tahoe, HP 9000/300:
  3604.            - most of P1003.1
  3605.            - NFS (from Sun)
  3606.            - MFS (memory file system)
  3607.            - OSI: TP4, CLNP, ISODE's FTAM, VT and X.500;  SLIP
  3608.            - Kerberos
  3609.  
  3610.          - Net1 (?) and Net2 (June 1991) tapes: that portion of BSD which
  3611.            requires no USL copyright
  3612.  
  3613.          - 4.4BSD (alpha June 1992) for HP 9000/300, Sparc, 386, DEC, others;
  3614.            neither VAX nor Tahoe; two versions, lite (~Net2 contents plus,
  3615.            fixes and new architectures) and encumbered (everything, requires
  3616.            USL license):
  3617.            - new virtual memory system (VMS) based on Mach 2.5
  3618.            - virtual filesystem interface, log-structured filesystem, size
  3619.              of local filesystem up to 2^63, NFS (freely redistributable,
  3620.              works with Sun's, over UDP or TCP)
  3621.            - ISO/OSI networking support (based on ISODE): TP4/CLNP/802.3 and
  3622.              TP0/CONS/X.25, session and above in user space;  FTAM, VT, X.500.
  3623.            - most of POSIX.1 (esp. new terminal driver a la SV), much of
  3624.              POSIX.2, improved job control; ANSI C headers
  3625.            - Kerberos integrated with much of the system (incl. NFS)
  3626.            - TCP/IP enhancements (incl. header prediction, SLIP)
  3627.            - important kernel changes (new system call convention, ...)
  3628.            - other improvements: FIFOs, byte-range file locking
  3629.            Official 4.4BSD release was expected within 6 months of above.
  3630.  
  3631.       The Open Software Foundation (OSF) released its Unix called OSF/1
  3632.          end of 1991.  Still requires an SVR2 license.
  3633.          Compatible/compliant with SVID 2 (and 3 coming), POSIX,
  3634.          X/Open, etc..  OSF members include Apollo, Dec, HP, IBM, ....
  3635.  
  3636.          - OSF/1 (1991):
  3637.            - based on Mach 2.5 kernel
  3638.            - symmetric multiprocessing, parallelized kernel, threads
  3639.            - logical volumes, disk mirroring, UFS (native), S5 FS, NFS
  3640.            - enhanced security (B1 with some B2, B3; or C2), 4.3BSD admin
  3641.            - STREAMS, TLI/XTI, sockets
  3642.            - shared libs, dynamic loader (incl. kernel)
  3643.            - Motif GUI
  3644.  
  3645.          - Future:
  3646.            - OSF/1 MK (mikrokernel) based on Mach 3.0
  3647.  
  3648.       This list of major flavors should probably also include Xenix
  3649.       (Microsoft) which has been the basis for many ports.  Derived from V7,
  3650.       S III and finally System V, it is similar externally but significantly
  3651.       changed internally (performance-tuned for micros).
  3652.  
  3653.  
  3654.       Two very good books describe the internals of the two main flavors.
  3655.       These are:
  3656.       - System V: "Design of the Unix Operating SYstem", M.J. Bach.
  3657.       - BSD: "Design and Implementation of the 4.3BSD Unix Operating System",
  3658.         Leffler, McKusick, Karels, Quaterman.
  3659.       For a good introduction to OSF/1 (not quite as technical as the
  3660.       previous two), see: "Guide to OSF/1, A Technical Synopsis",
  3661.       published by O'Reilly.  On SunOS, "Virtual Memory Architecture in
  3662.       SunOS" and "Shared Libraries in SunOS" in Summer 1989 USENIX
  3663.       Proceedings.
  3664.  
  3665.       A good set of articles on where Unix is going is "Unix Variants"
  3666.       in the Apr 92 issue of Unix Review.  Other good sources of
  3667.       information include the bsd-faq file, and many of the newsgroups
  3668.       mentioned in the text.
  3669.  
  3670. ------------------------------
  3671.  
  3672. Subject: Unix Standards.
  3673. From: "Pierre (P.) Lewis" <lew@bnr.ca>
  3674. Date: Wed Nov 17 11:21:35 EST 1993
  3675. X-Version: 2.5
  3676.  
  3677. 6.4)  Unix Standards.
  3678.  
  3679.       This section briefly describes the more important standards
  3680.       relevant to Unix.
  3681.  
  3682.       - IEEE:
  3683.         - 802.x (LAN) standards (LLC, ethernet, token ring, token bus)
  3684.         - POSIX (ISO 9945?): Portable Operating System I/F (Unix, VMS
  3685.           and OS/2!) (only ? have been finalized at this point)
  3686.           - 1003.1:  library procedures (mostly system calls) -- roughly V7
  3687.                      except for signals and terminal I/F (1990)
  3688.           - 1003.2:  shell and utilities
  3689.           - 1003.3:  test methods and conformance
  3690.           - 1003.4:  real-time: binary semaphores, process memory
  3691.                      locking, memory-mapped files, shared memory,
  3692.                      priority scheduling, real-time signals, clocks and
  3693.                      timers, IPC message passing, synchronized I/O,
  3694.                      asynchronous I/O, real-time files
  3695.           - 1003.5:  Ada language bindings
  3696.           - 1003.6:  security
  3697.           - 1003.7:  system admin (incl. printing)
  3698.           - 1003.8:  transparent file access
  3699.           - 1003.9:  FORTRAN language bindings
  3700.           - 1003.10: super computing
  3701.           - 1003.12: protocol-independent I/Fs
  3702.           - 1003.13: real-time profiles
  3703.           - 1003.15: supercomputing batch I/Fs
  3704.           - 1003.16: C-language bindings (?)
  3705.           - 1003.17: directory services
  3706.           - 1003.18: POSIX standardized profile
  3707.           - 1003.19: FORTRAN 90 language bindings
  3708.  
  3709.       - X/Open (consortium of vendors, founded 1984):
  3710.         - X/Open Portability Guides (XPGn):
  3711.           - XPG2 (1987), strong SV influence
  3712.             Vol 1:  commands and utilities
  3713.             Vol 2:  system calls and libraries
  3714.             Vol 3:  terminal I/F (curses, termio), IPC (SV),
  3715.                     internationalization
  3716.             Vol 4:  programming languages (C, COBOL!)
  3717.             Vol 5:  data management (ISAM, SQL)
  3718.           - XPG3 (1989) adds: X11 API
  3719.           - XPG4 (1992) adds: XTI?   22 components
  3720.         - XOM series of interfaces:
  3721.           - XOM (X/Open Object Management) generic I/F mechanisms for
  3722.             following
  3723.           - XDS (X/Open Directory Service)
  3724.           - XMH (X/Open Mail ??)
  3725.           - XMP (X/Open Management Protocols) -- not Bull's CM API?
  3726.         - X/Open now has the rights to the "UNIX" trademark (late 93);
  3727.         - "Spec 1170"
  3728.           - This specification is being prepared describing a common API
  3729.             which vendors wanting to use the name "UNIX" will have to comply
  3730.             with (when test suites are available). Merge of SVID3, OSF's AES
  3731.             and other stuff.
  3732.  
  3733.       - AT&T
  3734.         - System V Interface Definition (SVID)
  3735.           - SVID1 (1985, SVR2)
  3736.             Vol 1:  system calls and libraries (similar to XPG2.1)
  3737.           - SVID2 (1986, SVR3)
  3738.             Vol 1:  system calls and libraries (base, kernel extensions)
  3739.             Vol 2:  commands and utilities (base, advanced, admin, software
  3740.                     development), terminal I/F
  3741.             Vol 3:  terminal I/F (again), STREAMS and TLI, RFS
  3742.           - SVID3 (19??, SVR4) adds
  3743.             Vol 4:  ??  &c
  3744.         - APIs
  3745.           - Transport Library Interface (TLI)
  3746.           - ACSE/Presentation Library Interface (APLI)
  3747.  
  3748. ------------------------------
  3749.  
  3750. Subject: Identifying your Unix flavor.
  3751. From: "Pierre (P.) Lewis" <lew@bnr.ca>
  3752. Date: Wed Nov 17 11:21:35 EST 1993
  3753. X-Version: 2.5
  3754.  
  3755. 6.5)  Identifying your Unix flavor.
  3756.  
  3757.       This section lists a number of things you can look at in
  3758.       attempting to identify the base flavor of your Unix.  Given the
  3759.       significant exchange of code and ideas between the various
  3760.       flavors and the many changes made by vendors, any statement such
  3761.       as "this Unix is an SVR2" is at best a statistical statement
  3762.       (except for some SVRn ports).  Also many Unices offer most of
  3763.       both worlds (either mixed as in SunOS or strictly separated as in
  3764.       Apollo?).  So this section is perhaps not very useful...
  3765.  
  3766.       The list of features in previous sections can also help.  For
  3767.       example, if a system has a poll(2) but no select(2), it is highly
  3768.       probable that it is derived from SVR3.  Also the name of the OS
  3769.       can provide a clue, as well as the logon message (e.g.  SGI's
  3770.       "Irix SVR3.3.2") or the output of "uname -a" command.  Available
  3771.       commands can also provide hints but this is probably less
  3772.       reliable than kernel features.  For example, the type of terminal
  3773.       initialization (inittab or ttys) is a more reliable indicator
  3774.       than the print subsystem.
  3775.  
  3776.       Feature           Typical in SVRx         Typical in xBSD
  3777.  
  3778.       kernel name       /unix                   /vmunix
  3779.       terminal init     /etc/inittab            /etc/ttys (only getty to 4.3)
  3780.       boot init         /etc/rc.d directories   /etc/rc.* files
  3781.       mounted FSs       /etc/mnttab             /etc/mtab
  3782.       usual shell       sh, ksh                 csh, #! hack
  3783.       native FS         S5 (blk: 512-2K)        UFS (blk: 4K-8K)
  3784.                         file names <= 14 bytes  file names < 255 bytes
  3785.       groups            need newgrp(1)          automatic membership
  3786.                         SVR4: multiple groups
  3787.       print subsystem   lp, lpstat, cancel      lpr, lpq, lprm (lpd daemon) ??
  3788.       terminal control  termio, terminfo,       termios (sgtty before 4.3reno)
  3789.                         SVR4: termios (POSIX)   termcap
  3790.       job control       >= SVR4                 yes
  3791.       ps command        ps -ef                  ps -aux
  3792.       multiple wait     poll                    select
  3793.       string fcns       memset, memcpy          bzero, bcopy
  3794.       process mapping   /proc  (SVR4)
  3795.  
  3796. ------------------------------
  3797.  
  3798. Subject: Brief notes on some well-known (commercial/PD) Unices.
  3799. From: "Pierre (P.) Lewis" <lew@bnr.ca>
  3800. Date: Wed Nov 17 11:21:35 EST 1993
  3801. X-Version: 2.5
  3802.  
  3803. 6.6)  Brief notes on some well-known (commercial/PD) Unices.
  3804.  
  3805.       (I am not at all satisfied with this section, unfortunately I
  3806.       have neither the time nor the documents to make it much better
  3807.       (wrt contents).  Should only list Unices known by a reasonably
  3808.       wide audience.  Small and non-US Unices welcome, e.g. Eurix.  In
  3809.       need of reformatting)
  3810.  
  3811.       This section lists (in alphabetical order) some of the better
  3812.       known Unices along with a brief description of their nature.
  3813.  
  3814.       AIX:  IBM's Unix, based on SVR2 (later up to SVR3.2?) with varying
  3815.          degrees of BSD extensions, for various hardwares.  Proprietary
  3816.          system admin (SMIT).  Both 850 and Latin-1 CPs.  Quite
  3817.          different from most Unices and among themselves.
  3818.          Newsgroup: comp.unix.aix.
  3819.          - 1.x (for 386 PS/2)
  3820.          - 2.x (for PC RTs)
  3821.          - 3.x (for RS/6000), paging kernel, logical volume manager, i18n;
  3822.            3.2 adds TLI/STREAMS.  SV-based with many enhancements.
  3823.          - AIX/ESA, runs native on S/370 and S/390 mainframes, based on OSF/1.
  3824.          AIX was to have been base for OSF/1 until Mach was chosen instead.
  3825.          I hope this subsection is converging :-)
  3826.  
  3827.       AOS (IBM):  4.3BSD port to IBM PC RT (for educational institutes).
  3828.          Don't confuse with DG's proprietary OS of same name.
  3829.  
  3830.       Arix:  SV
  3831.  
  3832.       A/UX (Apple): SV with Berkeley enhancements, NFS, Mac GUI.  System 6
  3833.          (later System 7) runs as guest of A/UX (opposite of MachTen).
  3834.          Newsgroup: comp.unix.aux.
  3835.          - 2.0:  SVR2 with 4.2BSD, system 6 Mac applications.
  3836.          - 3.0 (1992): SVR2.2 with 4.3BSD and SVR3/4 extensions; X11R4,
  3837.            MacX, TCP/IP, NFS, NIS, RPC/XDR, various shells, UFS or S5FS.
  3838.            System 7 applications.
  3839.          - 4.0 will have/be OSF/1.
  3840.  
  3841.       BOS for Bull's DPX/2 (680x0)
  3842.          - V1 (1990): SVR3 with BSD extensions (FFS, select, sockets),
  3843.            symmetric MP, X11R3
  3844.          - V2 (1991): adds job control, disk mirroring, C2 security,
  3845.            DCE extensions
  3846.  
  3847.       386BSD: Jolitz's port of Net2 software.  Posix, 32-bit, still in alpha.
  3848.  
  3849.       BSD/386 (80386):  from BSDI, with source (augmented Net2 software)
  3850.          Newsgroup: comp.unix.bsd.
  3851.  
  3852.       Chorus/MiXV:  Unix SVR3.2 (SVR4) over Chorus nucleus, ABI/BCS.
  3853.  
  3854.       Coherent (80286):  Unix clone compatible with V7, some SVR2 (IPC).
  3855.          V4.0 is 32-bit.  Newsgroup: comp.os.coherent
  3856.  
  3857.       Consensys: SVR4.2
  3858.  
  3859.       CTIX: SV-based, from Convergent
  3860.  
  3861.       D-NIX:  SV
  3862.  
  3863.       DC/OSx (Pyramid):  SVR4.
  3864.  
  3865.       DELL UNIX [DELL Computer Corp.]: SVR4
  3866.  
  3867.       DomainIX: see DomainOS below.
  3868.  
  3869.       DomainOS (Apollo, now HP): proprietary OS; layered on top is BSD4.3 and
  3870.          SVR3 (a process can use either, neither or both).  Development now
  3871.          stopped, some features now in OSF/1 (and NT).  Now at SR10.4.
  3872.          Name for SR9.* was DomainIX.  Newsgroup: comp.sys.apollo.
  3873.  
  3874.       DVIX (NT's DVS):  SVR2
  3875.  
  3876.       DYNIX (Sequent): 4.2BSD-based
  3877.  
  3878.       DYNIX/PTX: SVR3-based
  3879.  
  3880.       Esix (80386):  pure SVR4, X11, OpenLook (NeWS), Xview
  3881.  
  3882.       Eurix (80?86):  SVR3.2 (Germany)
  3883.  
  3884.       FTX: Stratus fault-tolerant OS (68K or i860-i960 hardware)
  3885.  
  3886.       Generics UNIX (80386): SVR4.03 (Germany)
  3887.  
  3888.       GNU Hurd (?):  vaporware from the Free Software Foundation (FSF):
  3889.          Unix emulator over Mach 3.0 kernel.  Many GNU tools are very
  3890.          popular (emacs) and used in the PD Unices.
  3891.  
  3892.       HP-UX (HP):  old from S III (SVRx), now SVR2 (4.2BSD?) with SV utilities
  3893.          (they have trouble making up their minds).
  3894.          - 6.5: SVR2
  3895.          - 7.0: SVR3.2, symlinks
  3896.          - 7.5
  3897.          - 8.0: BSD based? for HP-9000 CISC (300/400) and RISC (800/700),
  3898.            shared libs
  3899.          - 9.0: includes DCE
  3900.  
  3901.       Interactive SVR3.2 (80x86): pure SVR3.  Interactive has been bought
  3902.          by Sun; will their system survive Solaris?
  3903.  
  3904.       Idris:  first Unix clone by Whitesmith.
  3905.          - 4D
  3906.  
  3907.       Irix (SGI):  SVR3.2, much BSD.  Newsgroup: comp.sys.sgi.
  3908.  
  3909.       Linux (80386):  PD Unix, conforms to POSIX.  Available with sources.
  3910.          Compatible with SVR3.2?  Newsgroup: comp.os.linux
  3911.  
  3912.       MachTen, Tenon Intersystems:  runs as a guest of System 6, no memory
  3913.          protection, 4.3BSD environment with TCP, NFS.
  3914.  
  3915.       MacMach (Mac II): 4.3BSD over Mach 3.0 microkernel, X11, Motif, GNU
  3916.          software, sources, experimental System 7 as Mach task.  Complete
  3917.          with all sources (need Unix license).
  3918.  
  3919.       Mach386: from Mt Xinu.  Based on Mach 2.5, with 4.3BSD-Tahoe
  3920.          enhancements.  Also 2.6 MSD (Mach Source Distribution).
  3921.  
  3922.       Microport (80x86):  pure SVR4, X11, OpenLook GUI
  3923.  
  3924.       Minix (80x86, Atari, Amiga, Mac):  Unix clone compatible with V7.
  3925.          Sold with sources.  Being POSIXified (sp?).  Newsgroup:
  3926. comp.os.minix.
  3927.  
  3928.       MipsOS:  SVish (RISC/OS, now dropped, was BSDish)
  3929.  
  3930.       more/BSD (VAX, HP 9000/300):  Mt Xinu's Unix, based on 4.3BSD-Tahoe.
  3931.          Newsgroup: comp.os.xinu?
  3932.  
  3933.       NCR UNIX: SVR4 (4.2?)
  3934.  
  3935.       Net/2 tape (from Berkeley, 1991): BSD Unix, essentially compatible with
  3936.          4.3BSD, includes only sources free of AT&T code, no low-level code.
  3937.          See 386BSD and BSD/386 above.
  3938.  
  3939.       NetBSD: much improved release of 386BSD (more stable and complete).
  3940.          Ported to [34]86, MIPS, Amiga, Sun, Mac. What is relation to Net/2?
  3941.  
  3942.       NextStep (Next):  BSD4.3 over Mach kernel, own GUI.
  3943.          - 1.x, 2.0 (old)
  3944.          - 2.1 (current)
  3945.          - 2.2 (support for NeXT Turbo machines)
  3946.          - 3.0 (now shipping, optimized for 68040 machines)
  3947.          - 3.1 (to be announced)
  3948.          - NeXTSTEP 486 Beta release is scheduled for the 4th quarter 1992.
  3949.  
  3950.       NEWS-OS (Sony)
  3951.          - 3.2
  3952.  
  3953.       OSF/1 (DEC): DEC's port of OSF/1.  I think this is now (4/93) available
  3954.          on DEC's latest Alpha AXP (64-bit machine).
  3955.  
  3956.       OSx (Pyramid): Dualport of both SysV.3 and BSD4.3.
  3957.  
  3958.       PC-IX (IBM 8086):  SV
  3959.  
  3960.       Plan 9 (AT&T): announced 1992, complete rewrite, not clear how close to
  3961.          Unix it is.  Key points: distributed, very small, various hardwares
  3962.          (Sun, Mips, Next, SGI, generic hobbit, 680x0, PCs), C (not C++ as
  3963.          rumors had it), new compiler, "8 1/2" window system (also very
  3964.          small), 16-bit Unicode, CPU/file servers over high speed nets.
  3965.  
  3966.       PowerOpen: announced Unix which is to run on the PowerPC chip (from
  3967.          IBM, Apple and Motorola).  Mac UI, compatibility to AIX.
  3968.  
  3969.       SCO Xenix (80x86): Versions for XT (not robust!), 286, 386 (with demand
  3970.          paging).  Today bulk of code is from System V.  Stable product.
  3971.  
  3972.       SCO Unix (80x86):  SVR3.2
  3973.  
  3974.       Sinix [Siemens]: System V base.
  3975.  
  3976.       Solaris (Sparc, 80386):
  3977.          - 1.0:  essentially same as SunOS 4.1.1, with OpenWindows 2.0 and
  3978.            DeskSet utilities.
  3979.          - 1.0.1:  SunOS 4.1.2 with multiprocessing (kernel not
  3980. multithreaded);
  3981.            not for 386
  3982.          - 2.0: (initially announced as SunOS 5.0 in 1988) based on SVR4
  3983.            (with symmetric MP?), will include support for 386; with
  3984.            OpenWindows 3.0 (X11R4) and OpenLook, DeskSet, ONC, NIS.  Both
  3985.            a.out (BSD) and elf (SVR4) formats.  Kerberos support.  Compilers
  3986.            unbundled!
  3987.  
  3988.       SunOS (680x0, Sparc, i386):  based on 4.3BSD, includes much from
  3989.          System V.  Main Sun achievements: NFS (1984), SunView (1985), NeWS
  3990.          (1986, postscript imaging, now in OpenWindows), OpenLook GUI
  3991. standard,
  3992.          OpenWindows (NeWS, X11, SunView!).  Newsgroup: comp.sys.sun.*.
  3993.          - 3.x:  SV IPC package, FIFOs
  3994.          - 4.0.3: lightweight processes, new virtual mem, shared libs
  3995.          - 4.1: STREAMS & TLI, 8-bit clean?, async I/O, ms-dos file system
  3996.          (continues as Solaris -- see above).
  3997.  
  3998.       UHC (80x86): pure SVR4, X11, Motif
  3999.  
  4000.       Ultrix (DEC):  based on 4.2BSD with much of 4.3.
  4001.          Newsgroup: comp.unix.ultrix.
  4002.          - 3.1, 4.0
  4003.  
  4004.       UNICOS (Cray):  System V base.  Newsgroup: comp.unix.cray
  4005.          - 5.x, 6,x, 7.0
  4006.  
  4007.       UTEK (Tektronix)
  4008.          - 4.0
  4009.  
  4010.       Xenix (80x86):  1st Unix on Intel hardware, based on SVR2 (previously on
  4011.          S III and even V7).  Newsgroup: comp.unix.xenix.
  4012.  
  4013.       3B1 (680x0): SV-based, done by Convergent for AT&T.
  4014.          Newsgroup: comp.sys.3b1.
  4015.  
  4016. ------------------------------
  4017.  
  4018. Subject: Real-time Unices.
  4019. From: "Pierre (P.) Lewis" <lew@bnr.ca>
  4020. Date: Wed Nov 17 11:21:35 EST 1993
  4021. X-Version: 2.5
  4022.  
  4023. 6.7)  Real-time Unices.
  4024.  
  4025.       WARNING: this section is badly in need of work. It's full of errors,
  4026.       and it's incomplete. I hope to have time to look at it this winter
  4027.       (was "this fall"). I doubt all of following are Unices -- input is
  4028.       welcome. The list also includes more common Unices with real-time
  4029.       features, and some non-Unix systems with Unix-like APIs. I don't
  4030.       suppose the latter really belong here, but having collected some notes,
  4031.       I'm hesitant to junk them. See also comp.realtime.
  4032.  
  4033.       Concurrent OS (Concurrent): real Unix, significantly modifed by
  4034.          Concurrent.
  4035.  
  4036.       EP/LX (Control Data): port of LynxOS to R3000. Formerly called TC/IX.
  4037.  
  4038.       LynxOS (Lynx Real-Time Systems, Inc): Berkeley and SV compatibility,
  4039.          ground-up rewrite (proprietary), predates SVR4. Is not UNIX, but
  4040.          supports much of the UNIX I/Fs. Fully preemptive, fixed priorities.
  4041.  
  4042.       MiX: microkernel implementation of SVR4 offered by Chorus.
  4043.  
  4044.       Motorola SVR4 has real-time capabilities.
  4045.  
  4046.       QNX (Quantum Software): unix-compatible real real-time OS.
  4047.  
  4048.       RTU (Concurrent), for 68K boxes
  4049.  
  4050.       Solaris 2 has real-time capabilities?
  4051.  
  4052.       Stellix (Stardent); it's Unix, but is it real-time?
  4053.  
  4054.       Venix/386: Interactive SVR3.2 with real-time extensions.
  4055.  
  4056.       VMEexec (Motorola): not Unix, but also shares some I/Fs with Unix.
  4057.  
  4058.       VxWorks (Wind River Systems): Little in common with Unix, has some I/Fs
  4059.          in common with Unix (but not the file system). Newsgroup:
  4060.          comp.os.vxworks.
  4061.  
  4062.         (know nothing about)
  4063.  
  4064.       Convex RTS
  4065.  
  4066.       REAL/IX (AEG)
  4067.  
  4068.       Sorix (Siemens)
  4069.  
  4070.       System V/86 (Motorola)
  4071.  
  4072.       TC/IX (CCD)
  4073.  
  4074.       Velocity (Ready Systems):
  4075.  
  4076.  
  4077. ------------------------------
  4078.  
  4079. Subject: Unix glossary.
  4080. From: "Pierre (P.) Lewis" <lew@bnr.ca>
  4081. Date: Wed Nov 17 11:21:35 EST 1993
  4082. X-Version: 2.5
  4083.  
  4084. 6.8)  Unix glossary.
  4085.  
  4086. · 
  4087. (continued next message)
  4088.  
  4089. -------------------------------------------------------------------------------
  4090. Area # 2120  news.answers           05-30-94 04:34      Message # 13354
  4091. From    : Ted Timar
  4092. To      : ALL                                           
  4093. Subj    : Unix - Frequently Asked
  4094.  
  4095.  @FROM   :tmatimar@isgtec.com                                          
  4096.  @SUBJECT:Unix - Frequently Asked Questions (6/7) [Frequent posting]   
  4097.  @PACKOUT:05-31-9440,3193382879                                        
  4098. · (Continued from last message)
  4099.  
  4100.       This section provides short definitions of various concepts and
  4101.       components of (or related to) Unix systems.
  4102.  
  4103.       Chorus: message-passing microkernel, may form basis for a future release
  4104.          of SV.  Chorus already have SVR4 running on top (binary-compatible).
  4105.  
  4106.       COSE (Common Open Software Environment) [Sun, HP, IBM]: common look and
  4107.          feel (Motif), common API.  Reaction against Windows NT.
  4108.  
  4109.       DCE (Distributed Computing Environment, from OSF): Includes RPC
  4110. (Apollo's
  4111.          NCS), directory service (local based on DNS, global on X.500), time,
  4112.          security, and threads services, DFS (distrib. file system), ....
  4113.          OS-independent.
  4114.  
  4115.       DME (Distributed Management Environment, from OSF):  future.
  4116.  
  4117.       FFS (Fast File System): from Berkeley, 1983.  Equivalent (exact?) of
  4118.          UFS in SunOS.  Has notions such as cylinder groups, fragments.
  4119.  
  4120.       Mach: modern kernels from CMU (Carnegie Mellon University) on which many
  4121.          Unices and other OSs are based (e.g. OSF/1, MacMach, ...):
  4122.          - 2.5: monolithic kernel with 4.2BSD
  4123.          - 3.0: microkernel with BSD Unix server in user space (and other OSs,
  4124.            e.g. MS-DOS)
  4125.          Newsgroup: comp.os.mach
  4126.  
  4127.       MFS (Memory File System):
  4128.  
  4129.       NeWS (Network extensible Window System), from Sun?: PostScript-based,
  4130.          networked, toolkits (and even clients) loaded in server.  Part of
  4131.          OpenWindows.
  4132.  
  4133.       NFS (Network File System):  contributed by Sun to BSD, stateless server
  4134.  
  4135.       ONC (Open Network Computing): from Sun(?), includes RPC, name service
  4136.          (NIS aka YP), NFS, ... (found in many Unices, other OSs).
  4137.  
  4138.       RFS (Remote File System):  SV, stateful server, incompatible with NFS
  4139.  
  4140.       RPC (Remote Procedure Call): high-level IPC (inter-process
  4141. communication)
  4142.          mechanism.  Two flavors.
  4143.          - ONC: Over TCP or UDP (later OSI), uses XDR to encode data.
  4144.          - DCE: has a different RPC mechanism (based on Apollo's NCS)
  4145.  
  4146.       S5 FS:  System V's native file system, blocks 512 to 2K.
  4147.  
  4148.       sockets:  BSD interface mechanism to networks (compare TLI).
  4149.  
  4150.       STREAMS:  a message-passing kernel mechanism, initially in SVR3, which
  4151.          provides a very good interface for protocol development.
  4152.  
  4153.       TFS (Translucent File System): Sun, COW applied to files.
  4154.  
  4155.       TLI (Transport Library Interface):  SV's interface to transport services
  4156.          (TCP, OSI).  UI has also defined an APLI (ACSE/Presentation Library
  4157.          Interface)
  4158.  
  4159.       UFS (?): BSD's native file system as seen in SunOS, blocks 4K to 8K,
  4160.          cylinder groups, fragments.
  4161.  
  4162.       XTI (X/Open Transport Interface):  TLI with enhancements
  4163.  
  4164.       X11: pixel-oriented window system from MIT.
  4165.  
  4166. ------------------------------
  4167.  
  4168. End of unix/faq Digest part 6 of 7
  4169. **********************************
  4170.  
  4171. --
  4172. Ted Timar - tmatimar@isgtec.com
  4173. ISG Technologies Inc., 6509 Airport Road, Mississauga, Ontario, Canada L4V 1S7
  4174.  
  4175.  
  4176. -------------------------------------------------------------------------------
  4177.